Part Number Hot Search : 
67YR20 E101K CS80C88 LR340 TE75A GP30K TS522 FRS9230D
Product Description
Full Text Search
 

To Download DSPIC30F6020BT-20E Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2006 microchip technology inc. advance information ds70178a dspic30f1010/202x data sheet 28/44-pin high-performance switch mode power supply digital signal controllers
ds70178a-page ii advance information ? 2006 microchip technology inc. information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyer?s risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, accuron, dspic, k ee l oq , micro id , mplab, pic, picmicro, picstart, pro mate, powersmart, rfpic and smartshunt are registered trademarks of micr ochip technology incorporated in the u.s.a. and other countries. amplab, filterlab, migratable memory, mxdev, mxlab, seeval, smartsensor and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, app lication maestro, dspicdem, dspicdem.net, dspicworks, ecan, economonitor, fansense, flexrom, fuzzylab, in-circuit serial programming, icsp, icepic, linear active thermistor, mindi, miwi, mpasm, mplib, mplink, pickit, picdem, picdem.net, piclab, pictail, powercal, powerinfo, powermate, powertool, real ice, rflab, rfpicdem, select mode, smart serial, smarttel, total endurance, uni/o, wiperlock and zena are tr ademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of mi crochip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2006, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the mo st secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specif ications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconductor manufacturer c an guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are co mmitted to continuously improvi ng the code protection features of our products. attempts to break microchip?s c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona, gresham, oregon and mountain view, california. the company?s quality system processes and procedures are for its picmicro ? 8-bit mcus, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001:2000 certified.
? 2006 microchip technology inc. advance information ds70178a-page 1 dspic30f1010/202x high-performance modified risc cpu: ? modified harvard architecture ? c compiler optimized instruction set architecture ? 83 base instructions with flexible addressing modes ? 24-bit wide instructions, 16-bit wide data path ? 12 kbytes on-chip flash program space ? 512 bytes on-chip data ram ? 16 x 16-bit working register array ? up to 30 mips operation: - dual internal rc 9.7 and 14.55 mhz (1%) - 32x pll with 480 mhz vco - pll inputs 3% - external ec clock 9.7 and 14.55 mhz - hs crystal mode 9.7 and 14.55 mhz ? 32 interrupt sources ? three external interrupt sources ? 8 user-selectable priority levels for each interrupt ? 4 processor exceptions and software traps dsp engine features: ? modulo and bit-reversed modes ? two 40-bit wide accumulators with optional saturation logic ? 17-bit x 17-bit single-cycle hardware fractional/ integer multiplier ? single-cycle multiply-accumulate (mac) operation ? 40-stage barrel shifter ? dual data fetch peripheral features: ? high-current sink/source i/o pins: 25 ma/25 ma ? three 16-bit timers/counters; optionally pair up 16-bit timers into 32-bit timer modules ? four 16-bit capture input functions ? two 16-bit compare/pwm output functions - dual compare mode available ? 3-wire spi modules (supports 4 frame modes) ?i 2 c tm module supports multi-master/slave mode and 7-bit/10-bit addressing ? uart module: - supports rs-232, rs-485 and lin 1.2 - supports irda ? with on-chip hardware endec - auto wake-up on start bit - auto-baud detect - 4-level fifo buffer smps pwm module features: ? four pwm generators with 8 outputs ? each pwm generator has independent time base and duty cycle ? duty cycle resolution of 1.1 ns at 30 mips ? individual dead time for each pwm generator: - dead-time resolution 4.2 ns at 30 mips - dead time for rising and falling edges ? phase-shift resolution of 4.2 ns @ 30 mips ? frequency resolution of 8.4 ns @ 30 mips ? pwm modes supported: - complementary -push-pull - multi-phase - variable phase - current reset - current-limit ? independent current-limit and fault inputs ? output override control ? special event trigger ? pwm generated adc trigger note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual? (ds70046). for more information on the device instruction set and programming, refer to the ?dspic30f/ 33f programmer?s reference manual? (ds70157). 28/44-pin dspic 30f1010/202x enha nced flash smps 16-bit digital signal controller
dspic30f1010/202x ds70178a-page 2 advance information ? 2006 microchip technology inc. analog features: adc ? 10-bit resolution ? 2000 ksps conversion rate ? up to 12 input channels ? ?conversion pairing? allows simultaneous conver- sion of two inputs (i.e., current and voltage) with a single trigger ? pwm control loop: - up to six conversion pairs available - each conversion pair has up to four pwm and seven other selectable trigger sources ? interrupt hardware supports up to 1m interrupts per second comparator ? four analog comparators: - 20 ns response time - 10-bit dac reference generator - programmable output polarity - selectable input source - adc sample and convert capable ? pwm module interface - pwm duty cycle control - pwm period control - pwm fault detect ? special event trigger ? pwm-generated adc trigger special microcontroller features: ? enhanced flash program memory: - 10,000 erase/write cycle (min.) for industrial temperature range, 100k (typical) ? self-reprogrammable under software control ? power-on reset (por), power-up timer (pwrt) and oscillator start-up timer (ost) ? flexible watchdog timer (wdt) with on-chip low power rc oscillator for reliable operation ? fail-safe clock monitor operation ? detects clock failure and switches to on-chip low power rc oscillator ? programmable code protection ? in-circuit serial programming? (icsp?) ? selectable power management modes - sleep, idle and alternate clock modes cmos technology: ? low-power, high-speed flash technology ? 3.0v and 5.0v operation (10%) ? industrial and extended temperature ranges ? low power consumption dspic30f switch mode power supply family : product pins packaging program memory (bytes) data sram (bytes) timers capture compare uart spi i 2 c? pwm adcs s & h a/d inputs analog comparators dspic30f1010 28sdip 6k 256 2011112x2126 ch 2 dspic30f1010 28soic 6k 256 2011112x2126 ch 2 dspic30f1010 28 qfn 6k 256 2011112x2126 ch 2 dspic30f2020 28sdip 12k 512 3121114x2148 ch 4 dspic30f2020 28soic 12k 512 3121114x2148 ch 4 dspic30f2020 28 qfn 12k 512 3121114x2148 ch 4 dspic30f2023 44 qfn 12k 512 3121114x21412 ch4 dspic30f2023 44tqfp12k 512 3121114x21412 ch4
? 2006 microchip technology inc. advance information ds70178a-page 3 dspic30f1010/202x pin diagrams 28-pin sdip and soic dspic30f1010 mclr pwm1l/re0 pwm1h/re1 pwm2l/re2 pwm2h/re3 re4 re5 v ss v dd an0/cmp1a/cn2/rb0 an1/cmp1b/cn3/rb1 av dd av ss an2/cmp1c/cmp2a/cn4/rb2 pgc2/emud2/sck1/sflt3/int2/rf6 pgd2/emuc2/oc1/sflt1/int1/rd0 emuc1/extref/t1ck/u1arx/cn0/re6 emud1/pgd1/u1atx/cn1/t2ck/re7 v ss osc2/clko/rb7 osc1/clki/rb6 v dd sflt2/int0/ocflta/ra9 pgc/emuc/sdi1/sda/u1rx/rf7 pgd/emud/sdo1/scl/u1tx/rf8 an5/cmp2d/cn7/rb5 an4/cmp2c/cn6/rb4 an3/cmp1d/cmp2b/cn5/rb3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 28 27 26 25 24 23 22 21 20 19 18 17 16 15 28-pin qfn 10 11 2 3 6 1 18 19 20 21 22 12 13 14 15 8 7 16 17 23 24 25 26 27 28 9 dspic30f1010 pgd1/emud1/t2ck/u1atx/cn1/re7 5 4 av dd av ss pwm1l/re0 pwm1h/re1 pwm2l/re2 pwm2h/re3 re4 re5 v dd v ss pgc/emuc/sdi1/sda/u1rx/rf7 pgd/emud/sdo1/scl/u1tx/rf8 sflt2/int0/ocflta/ra9 pgc2/emuc2/oc1/sflt1/ic1/int1/rd0 mclr an0/cmp1a/cn2/rb0 an1/cmp1b/cn3/rb1 an2/cmp1c/cmp2a/cn4/rb2 an3/cmp1d/cmp2b/cn5/rb3 an4/cmp2c/cn6/rb4 an5/cmp2d/cn7/rb5 v ss osc1/clki/rb6 osc2/clko/rb7 pgc1/emuc1/extref/u1arx/t1ck/cn0/re6 v dd pgd2/emud2/sck1/sflt3/int2/rf6
dspic30f1010/202x ds70178a-page 4 advance information ? 2006 microchip technology inc. 28-pin sdip and soic dspic30f2020 mclr pwm1l/re0 pwm1h/re1 pwm2l/re2 pwm2h/re3 pwm3l/re4 pwm3h/re5 v ss v dd an0/cmp1a/cn2/rb0 an1/cmp1b/cn3/rb1 av dd av ss an2/cmp1c/cmp2a/cn4/rb2 pgd2/emud2/sck1/sflt3/oc2/int2/rf6 pgc2/emuc2/oc1/sflt1/ic1/int1/rd0 emuc1/pgc1/extref/pwm4l/u1arx/cn0/t1ck/re6 pgd1/emud1/pwm4h/u1atx/cn1/t2ck/re7 v ss an7/cmp3d/cmp4b/osc2/clko/rb7 an6/cmp3c/cmp4a/osc1/clki/rb6 v dd sflt2/int0/ocflta/ra9 pgc/emuc/sdi1/sda/u1rx/rf7 pgd/emud/sdo1/scl/u1tx/rf8 an5/cmp2d/cmp3b/cn7/rb5 an4/cmp2c/cmp3a/cn6/rb4 an3/cmp1d/cmp2b/cn5/rb3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 28 27 26 25 24 23 22 21 20 19 18 17 16 15 28-pin qfn 10 11 2 3 6 1 18 19 20 21 22 12 13 14 15 8 7 16 17 23 24 25 26 27 28 9 dspic30f2020 pgd1/emud1/pwm4h/t2ck/u1atx/cn1/re7 5 4 av dd av ss pwm1l/re0 pwm1h/re1 pwm2l/re2 pwm2h/re3 pwm3l/re4 pwm3h/re5 v dd v ss pgc/emuc/sdi1/sda/u1rx/rf7 pgd/emud/sdo1/scl/u1tx/rf8 sflt2/int0/ocflta/ra9 pgc2/emuc2/oc1/sflt1/ic1/int1/rd0 mclr an0/cmp1a/cn2/rb0 an1/cmp1b/cn3/rb1 an2/cmp1c/cmp2a/cn4/rb2 an3/cmp1d/cmp2b/cn5/rb3 an4/cmp2c/cmp3a/cn6/rb4 an5/cmp2d/cmp3b/cn7/rb5 v ss an6/cmp3c/cmp4a/osc1/clki/rb6 an7/cmp3d/cmp4b/osc2/clko/rb7 pgc1/emuc1/extref/pwm4l/t1ck/u1arx/cn0/re6 v dd pgd2/emud2/sck1/sflt3/oc2/int2/rf6
? 2006 microchip technology inc. advance information ds70178a-page 5 dspic30f1010/202x pin diagrams 44-pin qfn 44 dspic30f2023 43 42 41 40 39 38 37 36 35 12 13 14 15 16 17 18 19 20 21 3 30 29 28 27 26 25 24 23 4 5 7 8 9 10 11 1 2 32 31 6 22 33 34 an4/cmp2c/cmp3a/cn6/rb4 an5/cmp2d/cmp3b/cn7/rb5 an6/cmp3c/cmp4a/osc1/clki/rb6 an7/cmp3d/cmp4b/osc2/clko/rb7 an8/cmp4c/rb8 an10/iflt4/rb10 v dd an11/iflt2/rb11 v ss pgd/emud/sdo1/rf8 an9/extref/cmp4d/rb9 pgc2/emuc2/oc1/ic1/int1/rd0 v dd pgc1/emuc1/pwm4l/t1ck/u1arx/cn0/re6 oc2/rd1 v ss sflt2/int0/ocflta/ra9 pgd2/emud2/sck1/int2/rf6 sflt1/ra8 pgd1/emud1 / pwm4h/t2ck/u1atx/cn1/re7 pwm2h/re3 pwm3l/re4 pwm3h/re5 v dd v ss synco/ssi/rf15 sda/rg3 sflt4/ra11 sflt3/ra10 pgc/emuc/sdi1/rf7 pwm2l/re2 an3/cmp1d/cmp2b/cn5/rb3 an2/cmp1c/cmp2a/cn4/rb2 emuc3/an1/cmp1b/cn3/rb1 emud3/an0/cmp1a/cn2/rb0 mclr u1rx/rf2 av dd av ss pwm1l/re0 pwm1h/re1 synci/rf14 u1tx/rf3 scl/ rg2
dspic30f1010/202x ds70178a-page 6 advance information ? 2006 microchip technology inc. pin diagrams 10 11 2 3 4 5 6 1 18 19 20 21 22 12 13 14 15 38 8 7 44 43 42 41 40 39 16 17 29 30 31 32 33 23 24 25 26 27 28 36 34 35 9 37 pgd/emud/sdo1/rf8 an9/extref/cmp4d/rb9 pgc2/emuc2/oc1/ic1/int1/rd0 v dd pgc1/emuc1/pwm4l/t1ck/u1arx/cn0/re6 synci/rf14 v ss sflt2/int0/ra9 pgd2/emud2/sck1/int2/rf6 sflt1/ra8 an3/cmp1d/cmp2b/cn5/rb3 an2/cmp1c/cmp2a/cn4/rb2 an1/emuc3/cmp1b/cn3/rb1 an0/emud3/cmp1a/cn2/rb0 mclr u1rx/rf2 av dd av ss pwm1l/re0 pwm1h/re1 pwm2h/re3 pwm3l/re4 pwm3h/re5 v dd v ss sda/rg3 sflt4/ra11 sflt3/ra10 pgc/emuc/sdi1/rf7 an4/cmp2c/cmp3a/cn6/rb4 an5/cmp2d/cmp3b/cn7/rb5 an6/cmp3c/cmp4a/osc1/clki/rb6 an7/cmp3d/cmp4b/osc2/clko/rb7 an8/cmp4c/rb8 synco/ssi/rf15 v dd v ss scl/rg2 u1tx/rf3 pgd1/emud1/pwm4h/t2ck/u1atx/cn1/re7 dspic30f2023 pwm2l/re2 oc2/rd1 an11/iflt2/rb11 an10/iflt4/rb10 44-pin tqfp
? 2006 microchip technology inc. advance information ds70178a-page 7 dspic30f1010/202x table of contents 1.0 device overview ............................................................................................................. ............................................................. 9 2.0 cpu architecture overview................................................................................................... ..................................................... 21 3.0 memory organization ......................................................................................................... ........................................................ 31 4.0 address generator units..................................................................................................... ....................................................... 43 5.0 interrupts .................................................................................................................. .................................................................. 49 6.0 i/o ports ................................................................................................................... .................................................................. 77 7.0 flash program memory........................................................................................................ ...................................................... 81 8.0 timer1 module ............................................................................................................... ............................................................ 87 9.0 timer2/3 module ............................................................................................................. ........................................................... 91 10.0 input capture module....................................................................................................... .......................................................... 97 11.0 output compare module ...................................................................................................... .................................................... 101 12.0 power supply pwm ........................................................................................................... ...................................................... 107 13.0 spi module................................................................................................................. .............................................................. 145 14.0 i 2 c? module...................................................................................................................... ...................................................... 149 15.0 universal asynchronous receiver transmitter (uart) module .................................................................. ............................ 157 16.0 10-bit 2 msps analog-to-digital conver ter (adc) module..................................................................... ................................... 165 17.0 smps comparator module ..................................................................................................... ................................................. 185 18.0 system integration ......................................................................................................... .......................................................... 191 19.0 instruction set summary .................................................................................................... ...................................................... 213 20.0 development support........................................................................................................ ....................................................... 221 21.0 electrical characteristics ................................................................................................. ......................................................... 225 22.0 package marking information................................................................................................ ................................................... 257
dspic30f1010/202x ds70178a-page 8 advance information ? 2006 microchip technology inc. to our valued customers it is our intention to provide our valued customers with the best documentation possible to ensure successful use of your micro chip products. to this end, we will continue to improve our publications to better suit your needs. our publications will be refined and enhanced as new volumes and updates are introduced. if you have any questions or comments regar ding this publication, please contact the marketing communications department via e-mail at docerrors@microchip.com or fax the reader response form in the back of this data sheet to (480) 792-4150. we welcome your feedback. most current data sheet to obtain the most up-to-date version of this data s heet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the vers ion number, (e.g., ds30000a is version a of document ds30000). errata an errata sheet, describing minor operational differences fr om the data sheet and recommended workarounds, may exist for curren t devices. as device/doc umentation issues become known to us, we will publis h an errata sheet. the errata will specify the revisi on of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particul ar device, please check with one of the following: ? microchip?s worldwide web site; http://www.microchip.com ? your local microchip sales office (see last page) when contacting a sales office, please spec ify which device, revision of silicon and data sheet (include literature number) you are using. customer notification system register on our web site at www.microchip.com to receive the most current information on all of our products.
? 2006 microchip technology inc. advance information ds70178a-page 9 dspic30f1010/202x 1.0 device overview this document contains device specific information for the dspic30f1010/202x smps devices. these devices contain extensive digital signal processor (dsp) func- tionality within a high-performance 16-bit microcontroller (mcu) architecture, as reflected in the following block diagrams. figure 1-1 and table 1-1 describe the dspic30f1010 smps device, figure 1-2 and table 1-2 describe the dspic30f2020 device and figure 1-3 and table 1-3 describe the dspic30f2023 smps device. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual? (ds70046). for more information on the device instruction set and programming, refer to the ? dspic30f/ 33f programmer?s reference manual? (ds70157).
dspic30f1010/202x ds70178a-page 10 advance information ? 2006 microchip technology inc. figure 1-1: dspic30f1010 block diagram power-up timer oscillator start-up timer por reset watchdog timer instruction decode & control osc1/clk1 mclr an4/cmp2c/cn6/rb4 uart1 spi1 smps pwm timing generation an5/cmp2d/cn7/rb5 16 pch pcl program counter alu<16> 16 address latch program memory (12 kbytes) data latch 24 24 24 24 x data bus ir i 2 c? comparator pcu pwm1l/re0 pwm1h/re1 pwm2l/re2 pwm2h/re3 re4 10-bit adc timers re5 pgc1/emuc1/extref/t1ck/ output compare module sflt2/int0/ocflta/ra9 portb pgc/emuc/sdi1/sda/u1rx/rf7 pgd/emud/sd01/scl/u1tx/rf8 portf portd 16 16 16 16 x 16 w reg array divide unit engine dsp decode rom latch 16 y data bus effective address x ragu x wagu y agu an0/cmp1a/cn2/rb0 an1/cmp1b/cn3/rb1 an2/cmp1c/cmp2a/cn4/rb2 an3/cmp1d/cmp2b/cn5/rb3 16 16 16 16 16 porta porte 16 16 16 16 8 interrupt controller psv & table data access control block stack control logic loop control logic data latch data latch y data (256 bytes) ram x data (256 bytes) ram address latch address latch control signals to various blocks pgc2/emuc2/oc1/sflt1/ 16 16 osc1/clki/rb6 osc2/clko/rb7 int1/rd0 pgd2/emud2/sck1/sflt3/ int2/rf6 pgd1/emud1/t2ck/u1atx/ module input change notification u1arx/cn0/re6 cn1/re7
? 2006 microchip technology inc. advance information ds70178a-page 11 dspic30f1010/202x table 1-1 provides a brief description of device i/o pinouts for the dspic30f1010 and the functions that may be multiplexed to a port pin. multiple functions may exist on one port pin. when multiplexing occurs, the peripheral module?s functional requirements may force an override of the data direction of the port pin. table 1-1: pinout i/o descriptions for dspic30f1010 pin name pin type buffer type description an0-an5 i analog analog input channels. av dd p p positive supply for analog module. av ss p p ground reference for analog module. clki clko i o st/cmos ? external clock source input. always associated with osc1 pin function. oscillator crystal output. connects to crystal or resonator in crystal oscillator mode. optionally functions as clko in rc and ec modes. always associated with osc2 pin function. emud emuc emud1 emuc1 emud2 emuc2 i/o i/o i/o i/o i/o i/o st st st st st st icd primary communication channel data input/output pin. icd primary communication channel clock input/output pin. icd secondary communication channel data input/output pin. icd secondary communication channel clock input/output pin. icd tertiary communication channel data input/output pin. icd tertiary communication channel clock input/output pin. int0 int1 int2 i i i st st st external interrupt 0 external interrupt 1 external interrupt 2 sflt1 sflt2 sflt3 pwm1l pwm1h pwm2l pwm2h i i i o o o o st st st ? ? ? ? shared fault pin 1 shared fault pin 2 shared fault pin 3 pwm 1 low output pwm 1 high output pwm 2 low output pwm 2 high output mclr i/p st master clear (reset) input or programming voltage input. this pin is an active low reset to the device. oc1 o ? compare outputs. ocflta i st output compare fault pin osc1 osc2 i i/o cmos ? oscillator crystal input. oscillator crystal output. connects to crystal or resonator in crystal oscillator mode. optionally functions as clko in frc and ec modes. pgd pgc pgd1 pgc1 pgd2 pgc2 i/o i i/o i i/0 i st st st st st st in-circuit serial programming? data input/output pin. in-circuit serial programming clock input pin. in-circuit serial programming data input/output pin 1. in-circuit serial programming clock input pin 1. in-circuit serial programming data input/output pin 2. in-circuit serial programming clock input pin 2. rb0-rb7 i/o st portb is a bidirectional i/o port. ra9 i/o st porta is a bidirectional i/o port. rd0 i/o st portd is a bidirectional i/o port. legend: cmos = cmos compatible input or output analog = analog input st = schmitt trigger input with cmos levels o = output i = input p = power
dspic30f1010/202x ds70178a-page 12 advance information ? 2006 microchip technology inc. re0-re7 i/o st porte is a bidirectional i/o port. rf6, rf7, rf8 i/o st portf is a bidirectional i/o port. sck1 sdi1 sdo1 ss1 i/o i o i st st ? st synchronous serial clock input/output for spi #1. spi #1 data in. spi #1 data out. spi #1 slave synchronization. scl sda i/o i/o st st synchronous serial clock input/output for i 2 c?. synchronous serial data input/output for i 2 c. t1ck t2ck i i st st timer1 external clock input. timer2 external clock input. u1rx u1tx u1arx u1atx i o i o st ? st ? uart1 receive. uart1 transmit. alternate uart1 receive. alternate uart1 transmit. cmp1a cmp1b cmp1c cmp1d cmp2a cmp2b cmp2c cmp2d i i i i i i i i analog analog analog analog analog analog analog analog comparator 1 channel a comparator 1 channel b comparator 1 channel c comparator 1 channel d comparator 2 channel a comparator 2 channel b comparator 2 channel c comparator 2 channel d cn0-cn7 i st input change notification inputs can be software programmed for internal weak pull-ups on all inputs. v dd p ? positive supply for logic and i/o pins. v ss p ? ground reference for logic and i/o pins. v ref + i analog analog voltage reference (high) input. v ref - i analog analog voltage reference (low) input. extref i analog external reference to comparator dac table 1-1: pinout i/o descriptions for dspic30f1010 (continued) pin name pin type buffer type description legend: cmos = cmos compatible input or output analog = analog input st = schmitt trigger input with cmos levels o = output i = input p = power
? 2006 microchip technology inc. advance information ds70178a-page 13 dspic30f1010/202x figure 1-2: dspic30f 2020 block diagram power-up timer oscillator start-up timer por reset watchdog timer instruction decode & control osc1/clk1 mclr an4/cmp2c/cmp3a/cn6/rb4 uart1 spi1 smps pwm timing generation an5/cmp2d/cmp3b/cn7/rb5 16 pch pcl program counter alu<16> 16 address latch program memory (12 kbytes) data latch 24 24 24 24 x data bus ir i 2 c? comparator pcu pwm1l/re0 pwm1h/re1 pwm2l/re2 pwm2h/re3 pwm3l/re4 10-bit adc timers pwm3h/re5 pgc1/emuc1/extref/pwm4l/ input capture module output compare module sflt2/int0/ocflta/ra9 portb pgc/emuc/sdi1/sda/u1rx/rf7 pgd/emud/sd01/scl/u1tx/rf8 portf portd 16 16 16 16 x 16 w reg array divide unit engine dsp decode rom latch 16 y data bus effective address x ragu x wagu y agu an0/cmp1a/cn2/rb0 an1/cmp1b/cn3/rb1 an2/cmp1c/cmp2a/cn4/rb2 an3/cmp1d/cmp2b/cn5/rb3 16 16 16 16 16 porta porte 16 16 16 16 8 interrupt controller psv & table data access control block stack control logic loop control logic data latch data latch y data (256 bytes) ram x data (256 bytes) ram address latch address latch control signals to various blocks pgc2/emuc2/oc1/sflt1/ic1/ 16 16 an6/cmp3c/cmp4a/ an7/cmp3d/cmp4b/ clki/osc1/rb6 clko/osc2/rb7 int1/rd0 pgd2/emud2/sck1/sflt3/oc2 / int2/rf6 pgd1/emud1/pwm4h/t2ck/ module input change notification u1arx/cn0/re6 u1atx/cn1/re7 t1ck/
dspic30f1010/202x ds70178a-page 14 advance information ? 2006 microchip technology inc. table 1-2 provides a brief description of device i/o pinouts for the dspic30f2020 and the functions that may be multiplexed to a port pin. multiple functions may exist on one port pin. when multiplexing occurs, the peripheral module?s functional requirements may force an override of the data direction of the port pin. table 1-2: pinout i/o descriptions for dspic30f2020 pin name pin type buffer type description an0-an7 i analog analog input channels. av dd p p positive supply for analog module. av ss p p ground reference for analog module. clki clko i o st/cmos ? external clock source input. always associated with osc1 pin function. oscillator crystal output. connects to crystal or resonator in crystal oscillator mode. optionally functions as clko in rc and ec modes. always associated with osc2 pin function. emud emuc emud1 emuc1 emud2 emuc2 i/o i/o i/o i/o i/o i/o st st st st st st icd primary communication channel data input/output pin. icd primary communication channel clock input/output pin. icd secondary communication channel data input/output pin. icd secondary communication channel clock input/output pin. icd tertiary communication channel data input/output pin. icd tertiary communication channel clock input/output pin. ic1 i st capture input. int0 int1 int2 i i i st st st external interrupt 0 external interrupt 1 external interrupt 2 sflt1 sflt2 sflt3 pwm1l pwm1h pwm2l pwm2h pwm3l pwm3h pwm4l pwm4h i i i o o o o o o o o st st st ? ? ? ? ? ? ? ? shared fault pin 1 shared fault pin 2 shared fault pin 3 pwm 1 low output pwm 1 high output pwm 2 low output pwm 2 high output pwm 3 low output pwm 3 high output pwm 4 low output pwm 4 high output mclr i/p st master clear (reset) input or programming voltage input. this pin is an active low reset to the device. oc1-oc2 ocflta o i ? compare outputs. output compare fault pin osc1 osc2 i i/o cmos ? oscillator crystal input. oscillator crystal output. connects to crystal or resonator in crystal oscillator mode. optionally functions as clko in frc and ec modes. pgd pgc pgd1 pgc1 pgd2 pgc2 i/o i i/o i i/o i st st st st st st in-circuit serial programming? data input/output pin. in-circuit serial programming clock input pin. in-circuit serial programming data input/output pin 1. in-circuit serial programming clock input pin 1. in-circuit serial programming data input/output pin 2. in-circuit serial programming clock input pin 2. legend: cmos = cmos compatible input or output analog = analog input st = schmitt trigger input with cmos levels o = output i = input p = power
? 2006 microchip technology inc. advance information ds70178a-page 15 dspic30f1010/202x rb0-rb7 i/o st portb is a bidirectional i/o port. ra9 i/o st porta is a bidirectional i/o port. rd0 i/o st portd is a bidirectional i/o port. re0-re7 i/o st porte is a bidirectional i/o port. rf6, rf7, rf8 i/o st portf is a bidirectional i/o port. sck1 sdi1 sdo1 ss1 i/o i o i st st ? st synchronous serial clock input/output for spi #1. spi #1 data in. spi #1 data out. spi #1 slave synchronization. scl sda i/o i/o st st synchronous serial clock input/output for i 2 c?. synchronous serial data input/output for i 2 c. t1ck t2ck i i st st timer1 external clock input. timer2 external clock input. u1rx u1tx u1arx u1atx i o i o st ? st o uart1 receive. uart1 transmit. alternate uart1 receive. alternate uart1 transmit. cmp1a cmp1b cmp1c cmp1d cmp2a cmp2b cmp2c cmp2d cmp3a cmp3b cmp3c cmp3d cmp4a cmp4b i i i i i i i i i i i i i i analog analog analog analog analog analog analog analog analog analog analog analog analog analog comparator 1 channel a comparator 1 channel b comparator 1 channel c comparator 1 channel d comparator 2 channel a comparator 2 channel b comparator 2 channel c comparator 2 channel d comparator 3 channel a comparator 3 channel b comparator 3 channel c comparator 3 channel d comparator 4 channel a comparator 4 channel b cn0-cn7 i st input change notification inputs can be software programmed for internal weak pull-ups on all inputs. v dd p ? positive supply for logic and i/o pins. v ss p ? ground reference for logic and i/o pins. v ref + i analog analog voltage reference (high) input. v ref - i analog analog voltage reference (low) input. extref i analog external reference to comparator dac table 1-2: pinout i/o descriptions for dspic30f2020 (continued) pin name pin type buffer type description legend: cmos = cmos compatible input or output analog = analog input st = schmitt trigger input with cmos levels o = output i = input p = power
dspic30f1010/202x ds70178a-page 16 advance information ? 2006 microchip technology inc. figure 1-3: dspic30f2023 block diagram power-up timer oscillator start-up timer por reset watchdog timer instruction decode & control osc1/clk1 mclr an4/cmp2c/cmp3a/cn6/rb4 uart1 spi1 smps pwm timing generation an5/cmp2d/cmp3b/cn7/rb5 16 pch pcl program counter alu<16> 16 address latch program memory (12 kbytes) data latch 24 24 24 24 x data bus ir i 2 c? comparator pcu pwm1l/re0 pwm1h/re1 pwm2l/re2 pwm2h/re3 pwm3l/re4 10-bit adc timers pwm3h/re5 pgc1/emuc1/pwm4l/t1ck/ input capture module output compare module portb scl/rg2 sda/rg3 portg portd 16 16 16 16 x 16 w reg array divide unit engine dsp decode rom latch 16 y data bus effective address x ragu x wagu y agu emud3/an0/cmp1a/cn2/rb0 emuc3/an1/cmp1b/cn3/rb1 an2/cmp1c/cmp2a/cn4/rb2 an3/cmp1d/cmp2b/cn5/rb3 16 16 16 16 16 porta porte 16 16 16 16 8 interrupt controller psv & table data access control block stack control logic loop control logic data latch data latch y data (256 bytes) ram x data (256 bytes) ram address latch address latch control signals to various blocks oc2/rd1 16 16 an6/cmp3c/cmp4a/ an7/cmp3d/cmp4b/ osc1/clki/rb6 osc2/clko/rb7 pgd1/emud1/pwm4h/t2ck/ module sflt1/ra8 sflt2/int0/ocflta/ra9 sflt3/ra10 pgc/emuc/sdi1/rf7 pgd/emud/sd01/rf8 portf pgd2/emud2/sck1/int2/rf6 an8/cmp4c/rb8 an9/extref/cmp4d/rb9 an10/iflt4/rb10 an11/iflt2/rb11 synci/rf14 pgc2/emuc2/oc1/ic1/int1/ sflt4/ra11 synco/ssi/rf15 u1tx/rf3 u1rx/rf2 input change notification u1arx/cn0/re6 u1atx/cn1/re7 rd0
? 2006 microchip technology inc. advance information ds70178a-page 17 dspic30f1010/202x table 1-3 provides a brief description of device i/o pinouts for the dspic30f2023 and the functions that may be multiplexed to a port pin. multiple functions may exist on one port pin. when multiplexing occurs, the peripheral module?s functional requirements may force an override of the data direction of the port pin. table 1-3: pinout i/o descriptions for dspic30f2023 pin name pin type buffer type description an0-an11 i analog analog input channels. av dd p p positive supply for analog module. av ss p p ground reference for analog module. clki clko i o st/cmos ? external clock source input. always associated with osc1 pin function. oscillator crystal output. connects to crystal or resonator in crystal oscillator mode. optionally functions as clko in rc and ec modes. always associated with osc2 pin function. emud emuc emud1 emuc1 emud2 emuc2 i/o i/o i/o i/o i/o i/o st st st st st st icd primary communication channel data input/output pin. icd primary communication channel clock input/output pin. icd secondary communication channel data input/output pin. icd secondary communication channel clock input/output pin. icd tertiary communication channel data input/output pin. icd tertiary communication channel clock input/output pin. ic1 i st capture input. int0 int1 int2 i i i st st st external interrupt 0 external interrupt 1 external interrupt 2 sflt1 sflt2 sflt3 sflt4 iflt2 iflt4 pwm1l pwm1h pwm2l pwm2h pwm3l pwm3h pwm4l pwm4h i i i i i i o o o o o o o o st st st st st st ? ? ? ? ? ? ? ? shared fault 1 shared fault 2 shared fault 3 shared fault 4 independent fault 2 independent fault 4 pwm 1 low output pwm 1 high output pwm 2 low output pwm 2 high output pwm 3 low output pwm 3 high output pwm 4 low output pwm 4 high output synco synci o i ? st pwm sync output pwm sync input mclr i/p st master clear (reset) input or programming voltage input. this pin is an active low reset to the device. oc1-oc2 ocflta o i ? st compare outputs. output compare fault condition. osc1 osc2 i i/o cmos ? oscillator crystal input. oscillator crystal output. connects to crystal or resonator in crystal oscillator mode. optionally functions as clko in frc and ec modes. legend: cmos = cmos compatible input or output analog = analog input st = schmitt trigger input with cmos levels o = output i = input p = power
dspic30f1010/202x ds70178a-page 18 advance information ? 2006 microchip technology inc. pgd pgc pgd1 pgc1 pgd2 pgc2 i/o i i/o i i/o i st st st st st st in-circuit serial programming? data input/output pin. in-circuit serial programming clock input pin. in-circuit serial programming data input/output pin 1. in-circuit serial programming clock input pin 1. in-circuit serial programming data input/output pin 2. in-circuit serial programming clock input pin 2. ra0,ra8- ra11 i/o st porta is a bidirectional i/o port. rb0-rb11 i/o st portb is a bidirectional i/o port. rd0,rd1 i/o st portd is a bidirectional i/o port. re0-re7 i/o st porte is a bidirectional i/o port. rf2, rf3, rf6-rf8, rf14, rf15 i/o st portf is a bidirectional i/o port. rg2, rg3 i/o st portg is a bidirectional i/o port. sck1 sdi1 sdo1 ss1 i/o i o i st st ? st synchronous serial clock input/output for spi #1. spi #1 data in. spi #1 data out. spi #1 slave synchronization. scl sda i/o i/o st st synchronous serial clock input/output for i 2 c. synchronous serial data input/output for i 2 c. t1ck t2ck i i st st timer1 external clock input. timer2 external clock input. u1rx u1tx u1arx u1atx i o i o st ? st ? uart1 receive. uart1 transmit. alternate uart1 receive. alternate uart1 transmit cmp1a cmp1b cmp1c cmp1d cmp2a cmp2b cmp2c cmp2d cmp3a cmp3b cmp3c cmp3d cmp4a cmp4b cmp4c cmp4d i i i i i i i i i i i i i i i i analog analog analog analog analog analog analog analog analog analog analog analog analog analog analog analog comparator 1 channel a comparator 1 channel b comparator 1 channel c comparator 1 channel d comparator 2 channel a comparator 2 channel b comparator 2 channel c comparator 2 channel d comparator 3 channel a comparator 3 channel b comparator 3 channel c comparator 3 channel d comparator 4 channel a comparator 4 channel b comparator 4 channel c comparator 4 channel d cn0-cn7 i st input change notification inputs can be software programmed for internal weak pull-ups on all inputs. v dd p ? positive supply for logic and i/o pins. v ss p ? ground reference for logic and i/o pins. v ref + i analog analog voltage reference (high) input. table 1-3: pinout i/o descriptions for dspic30f2023 (continued) pin name pin type buffer type description legend: cmos = cmos compatible input or output analog = analog input st = schmitt trigger input with cmos levels o = output i = input p = power
? 2006 microchip technology inc. advance information ds70178a-page 19 dspic30f1010/202x v ref - i analog analog voltage reference (low) input. extref i analog external reference to comparator dac table 1-3: pinout i/o descriptions for dspic30f2023 (continued) pin name pin type buffer type description legend: cmos = cmos compatible input or output analog = analog input st = schmitt trigger input with cmos levels o = output i = input p = power
dspic30f1010/202x ds70178a-page 20 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 21 dspic30f1010/202x 2.0 cpu architecture overview this document provides a summary of the dspic30f1010/202x cpu and peripheral function. for a complete description of this functionality, please refer to the ? dspic30f family reference manual? (ds70046). 2.1 core overview the core has a 24-bit instruction word. the program counter (pc) is 23 bits wide with the least significant bit (lsb) always clear (see section 3.1 ?program address space? ), and the most significant bit (msb) is ignored during normal program execution, except for certain specialized instructions. thus, the pc can address up to 4m instruction words of user program space. an instruction prefetch mechanism is used to help maintain throughput. program loop constructs, free from loop count management overhead, are sup- ported using the do and repeat instructions, both of which are interruptible at any point. the working register array consists of 16x16-bit regis- ters, each of which can act as data, address or offset registers. one working register (w15) operates as a software stack pointer for interrupts and calls. the data space is 64 kbytes (32k words) and is split into two blocks, referred to as x and y data memory. each block has its own independent address genera- tion unit (agu). most instructions operate solely through the x memory agu, which provides the appearance of a single unified data space. the multiply-accumulate ( mac ) class of dual source dsp instructions operate through both the x and y agus, splitting the data address space into two parts (see section 3.2 ?data address space? ). the x and y data space boundary is device-specific and cannot be altered by the user. each data word consists of 2 bytes, and most instructions can address data either as words or bytes. there are two methods of accessing data stored in program memory: ? the upper 32 kbytes of data space memory can be mapped into the lower half (user space) of program space at any 16k program word boundary, defined by the 8-bit program space visibility page (psvpag) register. this lets any instruction access program space as if it were data space, with a limita- tion that the access requires an additional cycle. moreover, only the lower 16 bits of each instruction word can be accessed using this method. ? linear indirect access of 32k word pages within program space is also possible using any working register, via table read and write instructions. table read and write instructions can be used to access all 24 bits of an instruction word. overhead-free circular buffers (modulo addressing) are supported in both x and y address spaces. this is pri- marily intended to remove the loop overhead for dsp algorithms. the x agu also supports bit-reversed addressing mode on destination effective addresses, to greatly simplify input or output data reordering for radix-2 fft algorithms. refer to section 4.0 ?address generator units? for details on modulo and bit-reversed addressing. the core supports inherent (no operand), relative, lit- eral, memory direct, register direct, register indirect, register offset and literal offset addressing modes. instructions are associated with predefined addressing modes, depending upon their functional requirements. for most instructions, the core is capable of executing a data (or program data) memory read, a working reg- ister (data) read, a data memory write and a program (instruction) memory read per instruction cycle. as a result, 3-operand instructions are supported, allowing c = a + b operations to be executed in a single cycle. a dsp engine has been included to significantly enhance the core arithmetic capability and throughput. it features a high-speed 17-bit by 17-bit multiplier, a 40-bit alu, two 40-bit saturating accumulators and a 40-bit bidirectional barrel shifter. data in the accumula- tor or any working register can be shifted up to 15 bits right or 16 bits left in a single cycle. the dsp instruc- tions operate seamlessly with all other instructions and have been designed for optimal real-time performance. the mac class of instructions can concurrently fetch two data operands from memory, while multiplying two w registers. to enable this concurrent fetching of data operands, the data space has been split for these instructions and linear for all others. this has been achieved in a transparent and flexible manner, by dedicating certain working registers to each address space for the mac class of instructions. the core does not support a multi-stage instruction pipeline. however, a single stage instruction prefetch mechanism is used, which accesses and partially decodes instructions a cycle ahead of execution, in order to maximize available execution time. most instructions execute in a single cycle, with certain exceptions. the core features a vectored exception processing structure for traps and interrupts, with 62 independent vectors. the exceptions consist of up to 8 traps (of which 4 are reserved) and 54 interrupts. each interrupt is prioritized based on a user-assigned priority between 1 and 7 (1 being the lowest priority and 7 being the highest) in conjunction with a predetermined ?natural order?. traps have fixed priorities, ranging from 8 to 15. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). for more information on the device instruction set and programming, refer to the ? dspic30f/ 33f programmer?s reference manual? (ds70157).
dspic30f1010/202x ds70178a-page 22 advance information ? 2006 microchip technology inc. 2.2 programmer?s model the programmer?s model is shown in figure 2-1 and consists of 16x16-bit working registers (w0 through w15), 2x40-bit accumulators (acca and accb), status register (sr), data table page register (tblpag), program space visibility page register (psvpag), do and repeat registers (dostart, doend, dcount and rcount), and program counter (pc). the working registers can act as data, address or offset registers. all registers are memory mapped. w0 acts as the w register for file register addressing. some of these registers have a shadow register asso- ciated with each of them, as shown in figure 2-1. the shadow register is used as a temporary holding register and can transfer its contents to or from its host register upon the occurrence of an event. none of the shadow registers are accessible directly. the following rules apply for transfer of registers into and out of shadows. ? push.s and pop.s w0, w1, w2, w3, sr (dc, n, ov, z and c bits only) are transferred. ? do instruction dostart, doend, dcount shadows are pushed on loop start, and popped on loop end. when a byte operation is performed on a working reg- ister, only the least significant byte (lsb) of the target register is affected. however, a benefit of memory mapped working registers is that both the least and most significant bytes (msbs) can be manipulated through byte wide data memory space accesses. 2.2.1 software stack pointer/ frame pointer the dspic ? dsc devices contain a software stack. w15 is the dedicated software stack pointer (sp), and will be automatically modified by exception processing and subroutine calls and returns. however, w15 can be referenced by any instruction in the same manner as all other w registers. this simplifies the reading, writing and manipulation of the stack pointer (e.g., creating stack frames). w15 is initialized to 0x0800 during a reset. the user may reprogram the sp during initialization to any location within data space. w14 has been dedicated as a stack frame pointer as defined by the lnk and ulnk instructions. however, w14 can be referenced by any instruction in the same manner as all other w registers. 2.2.2 status register the dspic dsc core has a 16-bit status register (sr), the lsb of which is referred to as the sr low byte (srl) and the msb as the sr high byte (srh). see figure 2-1 for sr layout. srl contains all the mcu alu operation status flags (including the z bit), as well as the cpu interrupt prior- ity level status bits, ipl<2:0>, and the repeat active status bit, ra. during exception processing, srl is concatenated with the msb of the pc to form a complete word value, which is then stacked. the upper byte of the status register contains the dsp adder/subtracter status bits, the do loop active bit (da) and the digit carry (dc) status bit. 2.2.3 program counter the program counter is 23 bits wide. bit 0 is always clear. therefore, the pc can address up to 4m instruction words. note: in order to protect against misaligned stack accesses, w15<0> is always clear.
? 2006 microchip technology inc. advance information ds70178a-page 23 dspic30f1010/202x figure 2-1: programmer?s model tabpag pc22 pc0 7 0 d0 d15 program counter data table page address status register working registers dsp operand registers w1 w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 w12/dsp offset w13/dsp write back w14/frame pointer w15/stack pointer dsp address registers ad39 ad0 ad31 dsp accumulators acca accb psvpag 7 0 program space visibility page address z 0 oa ob sa sb rcount 15 0 repeat loop counter dcount 15 0 do loop counter dostart 22 0 do loop start address ipl2 ipl1 splim stack pointer limit register ad15 srl push.s shadow do shadow oab sab 15 0 core configuration register legend corcon da dc ra n tblpag psvpag ipl0 ov w0/wreg srh do loop end address doend 22 c
dspic30f1010/202x ds70178a-page 24 advance information ? 2006 microchip technology inc. 2.3 divide support the dspic dsc devices feature a 16/16-bit signed fractional divide operation, as well as 32/16-bit and 16/ 16-bit signed and unsigned integer divide operations, in the form of single instruction iterative divides. the following instructions and data sizes are supported: 1. divf ? 16/16 signed fractional divide 2. div.sd ? 32/16 signed divide 3. div.ud ? 32/16 unsigned divide 4. div.sw ? 16/16 signed divide 5. div.uw ? 16/16 unsigned divide the 16/16 divides are similar to the 32/16 (same number of iterations), but the dividend is either zero-extended or sign-extended during the first iteration. the divide instructions must be executed within a repeat loop. any other form of execution (e.g. a series of discrete divide instructions) will not function correctly because the instruction flow depends on rcount. the divide instruction does not automatically set up the rcount value, and it must, therefore, be explicitly and correctly specified in the repeat instruc- tion, as shown in table 2-1 ( repeat will execute the target instruction {operand value + 1} times). the repeat loop count must be set up for 18 iterations of the div/divf instruction. thus, a complete divide operation requires 19 cycles. table 2-1: divide instructions note: the divide flow is interruptible. however, the user needs to save the context as appropriate. instruction function divf signed fractional divide: wm/wn w0; rem w1 div.sd signed divide: (wm + 1:wm)/wn w0; rem w1 div.sw (or div.s) signed divide: wm / wn w0; rem w1 div.ud unsigned divide: (wm + 1:wm)/wn w0; rem w1 div.uw (or div.u) unsigned divide: wm / wn w0; rem w1
? 2006 microchip technology inc. advance information ds70178a-page 25 dspic30f1010/202x 2.4 dsp engine the dsp engine consists of a high speed 17-bit x 17-bit multiplier, a barrel shifter, and a 40-bit adder/sub- tracter (with two target accumulators, round and saturation logic). the dsp engine also has the capability to perform inher- ent accumulator-to-accumulator operations, which require no additional data. these instructions are add, sub and neg . the dsp engine has various options selected through various bits in the cpu core configuration register (corcon), as listed below: 1. fractional or integer dsp multiply (if). 2. signed or unsigned dsp multiply (us). 3. conventional or convergent rounding (rnd). 4. automatic saturation on/off for acca (sata). 5. automatic saturation on/off for accb (satb). 6. automatic saturation on/off for writes to data memory (satdw). 7. accumulator saturation mode selection (accsat). a block diagram of the dsp engine is shown in figure 2-2. note: for corcon layout, see table 3-3. table 2-2: dsp instruction summary instruction algebraic operation acc wb? clr a = 0 yes ed a = (x ? y) 2 no edac a = a + (x ? y) 2 no mac a = a + (x * y) yes mac a = a + x 2 no movsac no change in a yes mpy a = x * y no mpy.n a = ? x * y no msc a = a ? x * y yes
dspic30f1010/202x ds70178a-page 26 advance information ? 2006 microchip technology inc. figure 2-2: dsp engine block diagram zero backfill sign-extend barrel shifter 40-bit accumulator a 40-bit accumulator b round logic x data bus to/from w array adder saturate negate 32 32 33 16 16 16 16 40 40 40 40 s a t u r a t e y data bus 40 carry/borrow out carry/borrow in 16 40 multiplier/scaler 17-bit
? 2006 microchip technology inc. advance information ds70178a-page 27 dspic30f1010/202x 2.4.1 multiplier the 17x17-bit multiplier is capable of signed or unsigned operation and can multiplex its output using a scaler to support either 1.31 fractional (q31) or 32-bit integer results. unsigned operands are zero-extended into the 17th bit of the multiplier input value. signed operands are sign-extended into the 17th bit of the mul- tiplier input value. the output of the 17x17-bit multiplier/ scaler is a 33-bit value, which is sign-extended to 40 bits. integer data is inherently represented as a signed two?s complement value, where the msb is defined as a sign bit. generally speaking, the range of an n-bit two?s complement integer is -2 n-1 to 2 n-1 ? 1. for a 16- bit integer, the data range is -32768 (0x8000) to 32767 (0x7fff), including 0. for a 32-bit integer, the data range is -2,147,483,648 (0x8000 0000) to 2,147,483,645 (0x7fff ffff). when the multiplier is configured for fractional multipli- cation, the data is represented as a two?s complement fraction, where the msb is defined as a sign bit and the radix point is implied to lie just after the sign bit (qx for- mat). the range of an n-bit two?s complement fraction with this implied radix point is -1.0 to (1-2 1-n ). for a 16-bit fraction, the q15 data range is -1.0 (0x8000) to 0.999969482 (0x7fff), including 0, and has a preci- sion of 3.01518x10 -5 . in fractional mode, a 16x16 mul- tiply operation generates a 1.31 product, which has a precision of 4.65661x10 -10 . the same multiplier is used to support the mcu multi- ply instructions, which include integer 16-bit signed, unsigned and mixed sign multiplies. the mul instruction may be directed to use byte or word sized operands. byte operands will direct a 16-bit result, and word operands will direct a 32-bit result to the specified register(s) in the w array. 2.4.2 data accumulators and adder/subtracter the data accumulator consists of a 40-bit adder/ subtracter with automatic sign extension logic. it can select one of two accumulators (a or b) as its pre- accumulation source and post-accumulation destina- tion. for the add and lac instructions, the data to be accumulated or loaded can be optionally scaled via the barrel shifter, prior to accumulation. 2.4.2.1 adder/subtracter, overflow and saturation the adder/subtracter is a 40-bit adder with an optional zero input into one side and either true or complement data into the other input. in the case of addition, the carry/borrow input is active high and the other input is true data (not complemented), whereas in the case of subtraction, the carry/borrow input is active low and the other input is complemented. the adder/subtracter generates overflow status bits sa/sb and oa/ob, which are latched and reflected in the status register. ? overflow from bit 39: this is a catastrophic overflow in which the sign of the accumulator is destroyed. ? overflow into guard bits 32 through 39: this is a recoverable overflow. this bit is set whenever all the guard bits are not identical to each other. the adder has an additional saturation block which controls accumulator data saturation, if selected. it uses the result of the adder, the overflow status bits described above, and the sata/b (corcon<7:6>) and accsat (corcon<4>) mode control bits to determine when and to what value to saturate. six status register bits have been provided to support saturation and overflow; they are: 1. oa: acca overflowed into guard bits 2. ob: accb overflowed into guard bits 3. sa: acca saturated (bit 31 overflow and saturation) or acca overflowed into guard bits and saturated (bit 39 overflow and saturation) 4. sb: accb saturated (bit 31 overflow and saturation) or accb overflowed into guard bits and saturated (bit 39 overflow and saturation) 5. oab: logical or of oa and ob 6. sab: logical or of sa and sb the oa and ob bits are modified each time data passes through the adder/subtracter. when set, they indicate that the most recent operation has overflowed into the accumulator guard bits (bits 32 through 39). the oa and ob bits can also optionally generate an arithmetic warning trap when set and the correspond- ing overflow trap flag enable bit (ovaten, ovbten) in the intcon1 register (refer to section 5.0 ?inter- rupts? ) is set. this allows the user to take immediate action, for example, to correct system gain.
dspic30f1010/202x ds70178a-page 28 advance information ? 2006 microchip technology inc. the sa and sb bits are modified each time data passes through the adder/subtracter, but can only be cleared by the user. when set, they indicate that the accumulator has overflowed its maximum range (bit 31 for 32-bit sat- uration, or bit 39 for 40-bit saturation) and will be satu- rated (if saturation is enabled). when saturation is not enabled, sa and sb default to bit 39 overflow and thus indicate that a catastrophic overflow has occurred. if the covte bit in the intcon1 register is set, sa and sb bits will generate an arithmetic warning trap when saturation is disabled. the overflow and saturation status bits can optionally be viewed in the status register (sr) as the logical or of oa and ob (in bit oab) and the logical or of sa and sb (in bit sab). this allows programmers to check one bit in the status register to determine if either accumulator has overflowed, or one bit to determine if either accumulator has saturated. this is useful for complex number arithmetic, which typically uses both the accumulators. the device supports three saturation and overflow modes. 1. bit 39 overflow and saturation: when bit 39 overflow and saturation occurs, the saturation logic loads the maximally positive 9.31 (0x7fffffffff) or maximally negative 9.31 value (0x8000000000) into the target accumula- tor. the sa or sb bit is set and remains set until cleared by the user. this is referred to as ?super saturation? and provides protection against erro- neous data or unexpected algorithm problems (e.g., gain calculations). 2. bit 31 overflow and saturation: when bit 31 overflow and saturation occurs, the saturation logic then loads the maximally positive 1.31 value (0x007fffffff) or maximally nega- tive 1.31 value (0x0080000000) into the target accumulator. the sa or sb bit is set and remains set until cleared by the user. when this saturation mode is in effect, the guard bits are not used (so the oa, ob or oab bits are never set). 3. bit 39 catastrophic overflow the bit 39 overflow status bit from the adder is used to set the sa or sb bit, which remain set until cleared by the user. no saturation operation is performed and the accumulator is allowed to overflow (destroying its sign). if the covte bit in the intcon1 register is set, a catastrophic overflow can initiate a trap exception. 2.4.2.2 accumulator ?write back? the mac class of instructions (with the exception of mpy, mpy.n, ed and edac ) can optionally write a rounded version of the high word (bits 31 through 16) of the accumulator that is not targeted by the instruction into data space memory. the write is performed across the x bus into combined x and y address space. the following addressing modes are supported: 1. w13, register direct: the rounded contents of the non-target accumulator are written into w13 as a 1.15 fraction. 2. [w13] + = 2, register indirect with post-incre- ment: the rounded contents of the non-target accumulator are written into the address pointed to by w13 as a 1.15 fraction. w13 is then incremented by 2 (for a word write). 2.4.2.3 round logic the round logic is a combinational block, which per- forms a conventional (biased) or convergent (unbiased) round function during an accumulator write (store). the round mode is determined by the state of the rnd bit in the corcon register. it generates a 16-bit, 1.15 data value which is passed to the data space write saturation logic. if rounding is not indicated by the instruction, a truncated 1.15 data value is stored and the least significant word (lsw) is simply discarded. conventional rounding takes bit 15 of the accumulator, zero-extends it and adds it to the accxh word (bits 16 through 31 of the accumulator). if the accxl word (bits 0 through 15 of the accumulator) is between 0x8000 and 0xffff (0x8000 included), accxh is incre- mented. if accxl is between 0x0000 and 0x7fff, accxh is left unchanged. a consequence of this algorithm is that over a succession of random rounding operations, the value will tend to be biased slightly positive. convergent (or unbiased) rounding operates in the same manner as conventional rounding, except when accxl equals 0x8000. if this is the case, the lsb (bit 16 of the accumulator) of accxh is examined. if it is ? 1 ?, accxh is incremented. if it is ? 0 ?, accxh is not modi- fied. assuming that bit 16 is effectively random in nature, this scheme will remove any rounding bias that may accumulate. the sac and sac.r instructions store either a trun- cated ( sac ) or rounded ( sac.r ) version of the contents of the target accumulator to data memory, via the x bus (subject to data saturation, see section 2.4.2.4 ?data space write saturation? ). note that for the mac class of instructions, the accumulator write back operation will function in the same manner, addressing combined mcu (x and y) data space though the x bus. for this class of instructions, the data is always subject to rounding.
? 2006 microchip technology inc. advance information ds70178a-page 29 dspic30f1010/202x 2.4.2.4 data space write saturation in addition to adder/subtracter saturation, writes to data space may also be saturated, but without affecting the contents of the source accumulator. the data space write saturation logic block accepts a 16-bit, 1.15 frac- tional value from the round logic block as its input, together with overflow status from the original source (accumulator) and the 16-bit round adder. these are combined and used to select the appropriate 1.15 frac- tional value as output to write to data space memory. if the satdw bit in the corcon register is set, data (after rounding or truncation) is tested for overflow and adjusted accordingly. for input data greater than 0x007fff, data written to memory is forced to the max- imum positive 1.15 value, 0x7fff. for input data less than 0xff8000, data written to memory is forced to the maximum negative 1.15 value, 0x8000. the msb of the source (bit 39) is used to determine the sign of the operand being tested. if the satdw bit in the corcon register is not set, the input data is always passed through unmodified under all conditions. 2.4.3 barrel shifter the barrel shifter is capable of performing up to 15-bit arithmetic or logic right shifts, or up to 16-bit left shifts in a single cycle. the source can be either of the two dsp accumulators or the x bus (to support multi-bit shifts of register or memory data). the shifter requires a signed binary value to determine both the magnitude (number of bits) and direction of the shift operation. a positive value will shift the operand right. a negative value will shift the operand left. a value of ? 0 ? will not modify the operand. the barrel shifter is 40 bits wide, thereby obtaining a 40-bit result for dsp shift operations and a 16-bit result for mcu shift operations. data from the x bus is pre- sented to the barrel shifter between bit positions 16 to 31 for right shifts, and bit positions 0 to 15 for left shifts.
dspic30f1010/202x ds70178a-page 30 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 31 dspic30f1010/202x 3.0 memory organization 3.1 program address space the program address space is 4m instruction words. it is addressable by a 24-bit value from either the 23-bit pc, table instruction effective address (ea), or data space ea, when program space is mapped into data space, as defined by table 3-1. note that the program space address is incremented by two between succes- sive program words, in order to provide compatibility with data space addressing. user program space access is restricted to the lower 4m instruction word address range (0x000000 to 0x7ffffe), for all accesses other than tblrd/tblwt , which use tblpag<7> to determine user or configura- tion space access. in table 3-1, read/write instruc- tions, bit 23 allows access to the device id, the user id and the configuration bits. otherwise, bit 23 is always clear. figure 3-1: program space memory map for dspic30f1010/ 202x note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). for more information on the device instruction set and programming, refer to the ? dspic30f/ 33f programmer?s reference manual? (ds70157). note: the address map shown in figure 3-1 is conceptual, and the actual memory con- figuration may vary across individual devices depending on available memory. reset ? target address user memory space 000000 7ffffe 00007e ext. osc. fail trap 000002 000080 user flash program memory 002000 001ffe address error trap stack error trap arithmetic warn. trap reserved reserved reserved vector 0 vector 1 vector 52 vector 53 (4k instructions) reserved (read 0 ?s) 0000fe 000100 000014 alternate vector table reset ? goto instruction 000004 reserved device configuration configuration memory space 800000 f80000 registers f8000e f80010 devid (2) fefffe ff0000 fffffe reserved f7fffe 8005fe 800600 unitid (32 instr.) 8005be 8005c0 reserved reserved vector tables
dspic30f1010/202x ds70178a-page 32 advance information ? 2006 microchip technology inc. table 3-1: program space address construction figure 3-2: data access from program space address generation access type access space program space address <23> <22:16> <15> <14:1> <0> instruction access user 0 pc<22:1> 0 tblrd/tblwt user (tblpag<7> = 0 ) tblpag<7:0> data ea <15:0> tblrd/tblwt configuration (tblpag<7> = 1 ) tblpag<7:0> data ea <15:0> program space visibility user 0 psvpag<7:0> data ea <14:0> 0 program counter 23 bits 1 psvpag reg 8 bits ea 15 bits program using select tblpag reg 8 bits ea 16 bits using byte 24-bit ea 0 0 1/0 select user/ configuration table instruction program space counter using space select note: program space visibility cannot be used to access bits <23:16> of a word in program memory. visibility
? 2006 microchip technology inc. advance information ds70178a-page 33 dspic30f1010/202x 3.1.1 data access from program memory using table instructions this architecture fetches 24-bit wide program memory. consequently, instructions are always aligned. how- ever, as the architecture is modified harvard, data can also be present in program space. there are two methods by which program space can be accessed; via special table instructions, or through the remapping of a 16k word program space page into the upper half of data space (see section 3.1.2 ?data access from program memory using program space visibility? ). the tblrdl and tblwtl instruc- tions offer a direct method of reading or writing the least significant word (lsw) of any address within program space, without going through data space. the tblrdh and tblwth instructions are the only method whereby the upper 8 bits of a program space word can be accessed as data. the pc is incremented by two for each successive 24-bit program word. this allows program memory addresses to directly map to data space addresses. program memory can thus be regarded as two 16-bit word wide address spaces, residing side by side, each with the same address range. tblrdl and tblwtl access the space which contains the least significant data word, and tblrdh and tblwth access the space which contains the most significant data byte. figure 3-2 shows how the ea is created for table oper- ations and data space accesses (psv = 1 ). here, p<23:0> refers to a program space word, whereas d<15:0> refers to a data space word. a set of table instructions is provided to move byte or word sized data to and from program space. 1. tblrdl: table read low word: read the lsw of the program address; p<15:0> maps to d<15:0>. byte: read one of the lsbs of the program address; p<7:0> maps to the destination byte when byte select = 0 ; p<15:8> maps to the destination byte when byte select = 1 . 2. tblwtl: table write low (refer to section 7.0 ?flash program memory? for details on flash programming). 3. tblrdh: table read high word: read the most significant word of the program address; p<23:16> maps to d<7:0>; d<15:8> always be = 0 . byte: read one of the msbs of the program address; p<23:16> maps to the destination byte when byte select = 0 ; the destination byte will always be = 0 when byte select = 1 . 4. tblwth: table write high (refer to section 7.0 ?flash program memory? for details on flash programming). figure 3-3: program data table access (least significant word) 0 8 16 pc address 0x000000 0x000002 0x000004 0x000006 23 00000000 00000000 00000000 00000000 program memory ?phantom? byte (read as ? 0 ?). tblrdl.w tblrdl.b (wn<0> = 1) tblrdl.b (wn<0> = 0)
dspic30f1010/202x ds70178a-page 34 advance information ? 2006 microchip technology inc. figure 3-4: program data table access (most significant byte) 3.1.2 data access from program memory using program space visibility the upper 32 kbytes of data space may optionally be mapped into any 16k word program space page. this provides transparent access of stored constant data from x data space, without the need to use special instructions (i.e., tblrdl/h, tblwtl/h instructions). program space access through the data space occurs if the msb of the data space ea is set and program space visibility is enabled, by setting the psv bit in the core control register (corcon). the functions of corcon are discussed in section 2.4 ?dsp engine? . data accesses to this area add an additional cycle to the instruction being executed, since two program memory fetches are required. note that the upper half of addressable data space is always part of the x data space. therefore, when a dsp operation uses program space mapping to access this memory region, y data space should typically con- tain state (variable) data for dsp operations, whereas x data space should typically contain coefficient (constant) data. although each data space address, 0x8000 and higher, maps directly into a corresponding program memory address (see figure 3-5), only the lower 16-bits of the 24-bit program word are used to contain the data. the upper 8 bits should be programmed to force an illegal instruction to maintain machine robustness. refer to the ? dspic30f/33f programmer?s reference manual? (ds70157) for details on instruction encoding. note that by incrementing the pc by 2 for each pro- gram memory word, the least significant 15 bits of data space addresses directly map to the least signif- icant 15 bits in the corresponding program space addresses. the remaining bits are provided by the pro- gram space visibility page register, psvpag<7:0>, as shown in figure 3-5. for instructions that use psv which are executed outside a repeat loop: ? the following instructions will require one instruc- tion cycle in addition to the specified execution time: - mac class of instructions with data operand prefetch - mov instructions - mov.d instructions ? all other instructions will require two instruction cycles in addition to the specified execution time of the instruction. for instructions that use psv which are executed inside a repeat loop: ? the following instances will require two instruction cycles in addition to the specified execution time of the instruction: - execution in the first iteration - execution in the last iteration - execution prior to exiting the loop due to an interrupt - execution upon re-entering the loop after an interrupt is serviced ? any other iteration of the repeat loop will allow the instruction, accessing data using psv, to execute in a single cycle. 0 8 16 pc address 0x000000 0x000002 0x000004 0x000006 23 00000000 00000000 00000000 00000000 program memory ?phantom? byte (read as ? 0 ?) tblrdh.w tblrdh.b (wn<0> = 1) tblrdh.b (wn<0> = 0) note: psv access is temporarily disabled during table reads/writes.
? 2006 microchip technology inc. advance information ds70178a-page 35 dspic30f1010/202x figure 3-5: data space window into program space operation 3.2 data address space the core has two data spaces. the data spaces can be considered either separate (for some dsp instruc- tions), or as one unified linear address range (for mcu instructions). the data spaces are accessed using two address generation units (agus) and separate data paths. 3.2.1 data space memory map the data space memory is split into two blocks, x and y data space. a key element of this architecture is that y space is a subset of x space, and is fully contained within x space. in order to provide an apparent linear addressing space, x and y spaces have contiguous addresses. when executing any instruction other than one of the mac class of instructions, the x block consists of the 256 byte data address space (including all y addresses). when executing one of the mac class of instructions, the x block consists of the 256 bytes data address space excluding the y address block (for data reads only). in other words, all other instructions regard the entire data memory as one composite address space. the mac class instructions extract the y address space from data space and address it using eas sourced from w10 and w11. the remaining x data space is addressed using w8 and w9. both address spaces are concurrently accessed only with the mac class instructions. a data space memory map is shown in figure 3-6. 23 15 0 psvpag (1) 15 15 ea<15> = 0 ea<15> = 1 16 data space ea data space program space 8 15 23 0x0000 0x8000 0xffff 0x00 0x100100 0x001ffe data read upper half of data space is mapped into program space note: psvpag is an 8-bit register, containing bits <22:15> of the program space address (i.e., it defines the page in program space to which the upper half of data space is being mapped). 0x001200 address concatenation bset corcon,#2 ; psv bit set mov #0x00, w0 ; set psvpag register mov w0, psvpag mov 0x9200, w0 ; access program memory location ; using a data space access
dspic30f1010/202x ds70178a-page 36 advance information ? 2006 microchip technology inc. figure 3-6: data space memory map 0x0000 0x07fe 0x08fe 0xfffe lsb address 16 bits lsb msb msb address 0x0001 0x07ff 0x08ff 0xffff 0x8001 0x8000 optionally mapped into program memory 0x09ff 0x09fe 0x0801 0x0800 0x0901 0x0900 near data sfr space 512 bytes sram space 2560 bytes note: unimplemented sfr or sram locations read as ? 0 ?. space unimplemented (x) x data sfr space x data ram (x) y data ram (y) (note) 256 bytes 256 bytes (see note) 0x0a00
? 2006 microchip technology inc. advance information ds70178a-page 37 dspic30f1010/202x figure 3-7: data space for mcu and dsp ( mac class) instructions sfr space (y space) x space sfr space unused x space x space y space unused unused non- mac class ops (read/write) mac class ops read-only indirect ea using any w indirect ea using w8, w9 indirect ea using w10, w11 mac class ops (write)
dspic30f1010/202x ds70178a-page 38 advance information ? 2006 microchip technology inc. 3.2.2 data spaces the x data space is used by all instructions and sup- ports all addressing modes. there are separate read and write data buses. the x read data bus is the return data path for all instructions that view data space as combined x and y address space. it is also the x address space data path for the dual operand read instructions ( mac class). the x write data bus is the only write path to data space for all instructions. the x data space also supports modulo addressing for all instructions, subject to addressing mode restric- tions. bit-reversed addressing is only supported for writes to x data space. the y data space is used in concert with the x data space by the mac class of instructions ( clr, ed, edac, mac, movsac, mpy, mpy.n and msc ) to pro- vide two concurrent data read paths. no writes occur across the y bus. this class of instructions dedicates two w register pointers, w10 and w11, to always address y data space, independent of x data space, whereas w8 and w9 always address x data space. note that during accumulator write back, the data address space is considered a combination of x and y data spaces, so the write occurs across the x bus. consequently, the write can be to any address in the entire data space. the y data space can only be used for the data prefetch operation associated with the mac class of instructions. it also supports modulo addressing for automated circular buffers. of course, all other instruc- tions can access the y data address space through the x data path, as part of the composite linear space. the boundary between the x and y data spaces is defined as shown in figure 3-6 and is not user pro- grammable. should an ea point to data outside its own assigned address space, or to a location outside phys- ical memory, an all-zero word/byte will be returned. for example, although y address space is visible by all non- mac instructions using any addressing mode, an attempt by a mac instruction to fetch data from that space, using w8 or w9 (x space pointers), will return 0x0000. table 3-2: effect of invalid memory accesses all effective addresses are 16 bits wide and point to bytes within the data space. therefore, the data space address range is 64 kbytes or 32k words. 3.2.3 data space width the core data width is 16 bits. all internal registers are organized as 16-bit wide words. data space memory is organized in byte addressable, 16-bit wide blocks. 3.2.4 data alignment to help maintain backward compatibility with picmicro ? mcu devices and improve data space memory usage efficiency, the dspic30f instruction set supports both word and byte operations. data is aligned in data memory and registers as words, but all data space eas resolve to bytes. data byte reads will read the complete word, which contains the byte, using the lsb of any ea to determine which byte to select. the selected byte is placed onto the lsb of the x data path (no byte accesses are possible from the y data path as the mac class of instruction can only fetch words). that is, data memory and registers are orga- nized as two parallel byte-wide entities with shared (word) address decode, but separate write lines. data byte writes only write to the corresponding side of the array or register which matches the byte address. as a consequence of this byte accessibility, all effective address calculations (including those generated by the dsp operations, which are restricted to word sized data) are internally scaled to step through word-aligned memory. for example, the core would recognize that post-modified register indirect addressing mode, [ws++], will result in a value of ws + 1 for byte operations and ws + 2 for word operations. all word accesses must be aligned to an even address. misaligned word data fetches are not supported, so care must be taken when mixing byte and word opera- tions, or translating from 8-bit mcu code. should a mis- aligned read or write be attempted, an address error trap will be generated. if the error occurred on a read, the instruction underway is completed, whereas if it occurred on a write, the instruction will be executed but the write will not occur. in either case, a trap will then be executed, allowing the system and/or user to exam- ine the machine state prior to execution of the address fault. figure 3-8: data alignment attempted operation data returned ea = an unimplemented address 0x0000 w8 or w9 used to access y data space in a mac instruction 0x0000 w10 or w11 used to access x data space in a mac instruction 0x0000 15 8 7 0 0001 0003 0005 0000 0002 0004 byte 1 byte 0 byte 3 byte 2 byte 5 byte 4 lsb msb
? 2006 microchip technology inc. advance information ds70178a-page 39 dspic30f1010/202x all byte loads into any w register are loaded into the lsb. the msb is not modified. a sign-extend ( se ) instruction is provided to allow users to translate 8-bit signed data to 16-bit signed values. alternatively, for 16-bit unsigned data, users can clear the msb of any w register by executing a zero-extend ( ze ) instruction on the appropriate address. although most instructions are capable of operating on word or byte data sizes, it should be noted that some instructions, including the dsp instructions, operate only on words. 3.2.5 near data space an 8 kbyte ?near? data space is reserved in x address memory space between 0x0000 and 0x1fff, which is directly addressable via a 13-bit absolute address field within all memory direct instructions. the remaining x address space and all of the y address space is addressable indirectly. additionally, the whole of x data space is addressable using mov instructions, which support memory direct addressing with a 16-bit address field. 3.2.6 software stack the dspic dsc device contains a software stack. w15 is used as the stack pointer. the stack pointer always points to the first available free word and grows from lower addresses towards higher addresses. it pre-decrements for stack pops and post-increments for stack pushes, as shown in figure 3-9. note that for a pc push during any call instruction, the msb of the pc is zero-extended before the push, ensuring that the msb is always clear. there is a stack pointer limit register (splim) associ- ated with the stack pointer. splim is uninitialized at reset. as is the case for the stack pointer, splim<0> is forced to ? 0 ?, because all stack operations must be word-aligned. whenever an effective address (ea) is generated using w15 as a source or destination pointer, the address thus generated is compared with the value in splim. if the contents of the stack pointer (w15) and the splim register are equal and a push operation is performed, a stack error trap will not occur. the stack error trap will occur on a subsequent push operation. thus, for example, if it is desirable to cause a stack error trap when the stack grows beyond address 0x2000 in ram, initialize the splim with the value, 0x1ffe. similarly, a stack pointer underflow (stack error) trap is generated when the stack pointer address is found to be less than 0x0800, thus preventing the stack from interfering with the special function register (sfr) space. a write to the splim register should not be immediately followed by an indirect read operation using w15. figure 3-9: call stack frame note: a pc push during exception processing will concatenate the srl register to the msb of the pc prior to the push. pc<15:0> 000000000 0 15 w15 (before call ) w15 (after call ) stack grows towards higher address push : [w15++] pop : [--w15] 0x0000 pc<22:16>
dspic30f1010/202x ds70178a-page 40 advance information ? 2006 microchip technology inc. table 3-3: core register map sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state w0 0000 w0 / wreg 0000 0000 0000 0000 w1 0002 w1 0000 0000 0000 0000 w2 0004 w2 0000 0000 0000 0000 w3 0006 w3 0000 0000 0000 0000 w4 0008 w4 0000 0000 0000 0000 w5 000a w5 0000 0000 0000 0000 w6 000c w6 0000 0000 0000 0000 w7 000e w7 0000 0000 0000 0000 w8 0010 w8 0000 0000 0000 0000 w9 0012 w9 0000 0000 0000 0000 w10 0014 w10 0000 0000 0000 0000 w11 0016 w11 0000 0000 0000 0000 w12 0018 w12 0000 0000 0000 0000 w13 001a w13 0000 0000 0000 0000 w14 001c w14 0000 0000 0000 0000 w15 001e w15 0000 1000 0000 0000 splim 0020 splim 0000 0000 0000 0000 accal 0022 accal 0000 0000 0000 0000 accah 0024 accah 0000 0000 0000 0000 accau 0026 sign-extension (acca<39>) accau 0000 0000 0000 0000 accbl 0028 accbl 0000 0000 0000 0000 accbh 002a accbh 0000 0000 0000 0000 accbu 002c sign-extension (accb<39>) accbu 0000 0000 0000 0000 pcl 002e pcl 0000 0000 0000 0000 pch 0030 ? ? ? ? ? ? ? ? ?pch 0000 0000 0000 0000 tblpag 0032 ? ? ? ? ? ? ? ?tblpag 0000 0000 0000 0000 psvpag 0034 ? ? ? ? ? ? ? ? psvpag 0000 0000 0000 0000 rcount 0036 rcount uuuu uuuu uuuu uuuu dcount 0038 dcount uuuu uuuu uuuu uuuu dostartl 003a dostartl 0 uuuu uuuu uuuu uuu0 dostarth 003c ? ? ? ? ? ? ? ? ?dostarth 0000 0000 0uuu uuuu doendl 003e doendl 0 uuuu uuuu uuuu uuu0 doendh 0040 ? ? ? ? ? ? ? ? ? doendh 0000 0000 0uuu uuuu sr 0042 oa ob sa sb oab sab da dc ipl2 ipl1 ipl0 ra n ov z c 0000 0000 0000 0000 corcon 0044 ? ? ? us edt dl2 dl1 dl0 sata satb satdw accsat ipl3 psv rnd if 0000 0000 0010 0000 legend: u = uninitialized bit
? 2006 microchip technology inc. advance information ds70178a-page 41 dspic30f1010/202x note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields. modcon 0046 xmoden ymoden ? ? bwm<3:0> ywm<3:0> xwm<3:0> 0000 0000 0000 0000 xmodsrt 0048 xs<15:1> 0 uuuu uuuu uuuu uuu0 xmodend 004a xe<15:1> 1 uuuu uuuu uuuu uuu1 ymodsrt 004c ys<15:1> 0 uuuu uuuu uuuu uuu0 ymodend 004e ye<15:1> 1 uuuu uuuu uuuu uuu1 xbrev 0050 bren xb<14:0> uuuu uuuu uuuu uuuu disicnt 0052 ? ? disicnt<13:0> 0000 0000 0000 0000 table 3-3: core register map (continued) sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state legend: u = uninitialized bit
dspic30f1010/202x ds70178a-page 42 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 43 dspic30f1010/202x 4.0 address generator units the dspic dsc core contains two independent address generator units: the x agu and y agu. the y agu supports word sized data reads for the dsp mac class of instructions only. the dspic dsc agus support three types of data addressing: ? linear addressing ? modulo (circular) addressing ? bit-reversed addressing linear and modulo data addressing modes can be applied to data space or program space. bit-reversed addressing is only applicable to data space addresses. 4.1 instruction addressing modes the addressing modes in table 4-1 form the basis of the addressing modes optimized to support the specific features of individual instructions. the addressing modes provided in the mac class of instructions are somewhat different from those in the other instruction types. 4.1.1 file register instructions most file register instructions use a 13-bit address field (f) to directly address data present in the first 8192 bytes of data memory (near data space). most file register instructions employ a working register, w0, which is denoted as wreg in these instructions. the destination is typically either the same file register, or wreg (with the exception of the mul instruction), which writes the result to a register or register pair. the mov instruction allows additional flexibility and can access the entire data space. table 4-1: fundamental addressing modes supported note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual? (ds70046). for more information on the device instruction set and programming, refer to the ? dspic30f/ 33f programmer?s reference manual? (ds70157). addressing mode description file register direct the address of the file register is specified explicitly. register direct the contents of a register are accessed directly. register indirect the contents of wn forms the ea. register indirect post-modified the contents of wn forms the ea. wn is post-modified (incremented or decremented) by a constant value. register indirect pre-modified wn is pre-modified (incremented or decremented) by a signed constant value to form the ea. register indirect with register offset the sum of wn and wb forms the ea. register indirect with literal offset the sum of wn and a literal forms the ea.
dspic30f1010/202x ds70178a-page 44 advance information ? 2006 microchip technology inc. 4.1.2 mcu instructions the three-operand mcu instructions are of the form: operand 3 = operand 1 operand 2 where operand 1 is always a working register (i.e., the addressing mode can only be register direct), which is referred to as wb. operand 2 can be a w register, fetched from data memory, or a 5-bit literal. the result location can be either a w register or an address location. the following addressing modes are supported by mcu instructions: ? register direct ? register indirect ? register indirect post-modified ? register indirect pre-modified ? 5-bit or 10-bit literal 4.1.3 move and accumulator instructions move instructions and the dsp accumulator class of instructions provide a greater degree of addressing flexibility than other instructions. in addition to the addressing modes supported by most mcu instruc- tions, move and accumulator instructions also support register indirect with register offset addressing mode, also referred to as register indexed mode. in summary, the following addressing modes are supported by move and accumulator instructions: ? register direct ? register indirect ? register indirect post-modified ? register indirect pre-modified ? register indirect with register offset (indexed) ? register indirect with literal offset ? 8-bit literal ? 16-bit literal 4.1.4 mac instructions the dual source operand dsp instructions ( clr, ed, edac, mac, mpy, mpy.n, movsac and msc ), also referred to as mac instructions, utilize a simplified set of addressing modes to allow the user to effectively manipulate the data pointers through register indirect tables. the two source operand prefetch registers must be a member of the set {w8, w9, w10, w11}. for data reads, w8 and w9 will always be directed to the x ragu and w10 and w11 will always be directed to the y agu. the effective addresses generated (before and after modification) must, therefore, be valid addresses within x data space for w8 and w9 and y data space for w10 and w11. in summary, the following addressing modes are supported by the mac class of instructions: ? register indirect ? register indirect post-modified by 2 ? register indirect post-modified by 4 ? register indirect post-modified by 6 ? register indirect with register offset (indexed) 4.1.5 other instructions besides the various addressing modes outlined above, some instructions use literal constants of various sizes. for example, bra (branch) instructions use 16-bit signed literals to specify the branch destination directly, whereas the disi instruction uses a 14-bit unsigned literal field. in some instructions, such as add acc , the source of an operand or result is implied by the opcode itself. certain operations, such as nop , do not have any operands. note: not all instructions support all the addressing modes given above. individual instructions may support different subsets of these addressing modes. note: for the mov instructions, the addressing mode specified in the instruction can differ for the source and destination ea. how- ever, the 4-bit wb (register offset) field is shared between both source and destination (but typically only used by one). note: not all instructions support all the addressing modes given above. individual instructions may support different subsets of these addressing modes. note: register indirect with register offset addressing is only available for w9 (in x space) and w11 (in y space).
? 2006 microchip technology inc. advance information ds70178a-page 45 dspic30f1010/202x 4.2 modulo addressing modulo addressing is a method of providing an auto- mated means to support circular data buffers using hardware. the objective is to remove the need for soft- ware to perform data address boundary checks when executing tightly looped code, as is typical in many dsp algorithms. modulo addressing can operate in either data or pro- gram space (since the data pointer mechanism is essen- tially the same for both). one circular buffer can be supported in each of the x (which also provides the pointers into program space) and y data spaces. modulo addressing can operate on any w register pointer. how- ever, it is not advisable to use w14 or w15 for modulo addressing, since these two registers are used as the stack frame pointer and stack pointer, respectively. in general, any particular circular buffer can only be configured to operate in one direction, as there are cer- tain restrictions on the buffer start address (for incre- menting buffers) or end address (for decrementing buffers) based upon the direction of the buffer. the only exception to the usage restrictions is for buff- ers which have a power-of-2 length. as these buffers satisfy the start and end address criteria, they may operate in a bidirectional mode, (i.e., address bound- ary checks will be performed on both the lower and upper address boundaries). 4.2.1 start and end address the modulo addressing scheme requires that a starting and an end address be specified and loaded into the 16-bit modulo buffer address registers: xmodsrt, xmodend, ymodsrt and ymodend (see table 3-3). the length of a circular buffer is not directly specified. it is determined by the difference between the corre- sponding start and end addresses. the maximum possible length of the circular buffer is 32k words (64 kbytes). 4.2.2 w address register selection the modulo and bit-reversed addressing control reg- ister modcon<15:0> contains enable flags as well as a w register field to specify the w address registers. the xwm and ywm fields select which registers will operate with modulo addressing. if xwm = 15, x ragu and x wagu modulo addressing are disabled. similarly, if ywm = 15, y agu modulo addressing is disabled. the x address space pointer w register (xwm) to which modulo addressing is to be applied, is stored in modcon<3:0> (see table 3-3). modulo addressing is enabled for x data space when xwm is set to any value other than 15 and the xmoden bit is set at modcon<15>. the y address space pointer w register (ywm) to which modulo addressing is to be applied, is stored in modcon<7:4>. modulo addressing is enabled for y data space when ywm is set to any value other than 15 and the ymoden bit is set at modcon<14>. note: y-space modulo addressing ea calcula- tions assume word sized data (lsb of every ea is always clear).
dspic30f1010/202x ds70178a-page 46 advance information ? 2006 microchip technology inc. figure 4-1: modulo addressing operation example 0x1100 0x1163 start addr = 0x1100 end addr = 0x1163 length = 0x0032 words byte address mov #0x1100,w0 mov w0, xmodsrt ;set modulo start address mov #0x1163,w0 mov w0,modend ;set modulo end address mov #0x8001,w0 mov w0,modcon ;enable w1, x agu for modulo mov #0x0000,w0 ;w0 holds buffer fill value mov #0x1110,w1 ;point w1 to buffer do again,#0x31 ;fill the 50 buffer locations mov w0, [w1++] ;fill the next location again: inc w0,w0 ;increment the fill value
? 2006 microchip technology inc. advance information ds70178a-page 47 dspic30f1010/202x 4.2.3 modulo addressing applicability modulo addressing can be applied to the effective address (ea) calculation associated with any w regis- ter. it is important to realize that the address bound- aries check for addresses less than or greater than the upper (for incrementing buffers) and lower (for decre- menting buffers) boundary addresses (not just equal to). address changes may, therefore, jump beyond boundaries and still be adjusted correctly. 4.3 bit-reversed addressing bit-reversed addressing is intended to simplify data re-ordering for radix-2 fft algorithms. it is supported by the x agu for data writes only. the modifier, which may be a constant value or register contents, is regarded as having its bit order reversed. the address source and destination are kept in normal order. thus, the only operand requiring reversal is the modifier. 4.3.1 bit-reversed addressing implementation bit-reversed addressing is enabled when: 1. bwm (w register selection) in the modcon register is any value other than 15 (the stack can not be accessed using bit-reversed addressing) and 2. the bren bit is set in the xbrev register and 3. the addressing mode used is register indirect with pre-increment or post-increment. if the length of a bit-reversed buffer is m = 2 n bytes, then the last ?n? bits of the data buffer start address must be zeros. xb<14:0> is the bit-reversed address modifier or ?pivot point? which is typically a constant. in the case of an fft computation, its value is equal to half of the fft data buffer size. when enabled, bit-reversed addressing will only be executed for register indirect with pre-increment or post-increment addressing and word sized data writes. it will not function for any other addressing mode or for byte sized data, and normal addresses will be gener- ated instead. when bit-reversed addressing is active, the w address pointer will always be added to the address modifier (xb) and the offset associated with the register indirect addressing mode will be ignored. in addition, as word sized data is a requirement, the lsb of the ea is ignored (and always clear). if bit-reversed addressing has already been enabled by setting the bren (xbrev<15>) bit, then a write to the xbrev register should not be immediately followed by an indirect read operation using the w register that has been designated as the bit-reversed pointer. figure 4-2: bit-reversed address example note: the modulo corrected effective address is written back to the register only when pre- modify or post-modify addressing mode is used to compute the effective address. when an address offset (e.g., [w7 + w2]) is used, modulo address correction is per- formed, but the contents of the register remains unchanged. note: all bit-reversed ea calculations assume word sized data (lsb of every ea is always clear). the xb value is scaled accordingly to generate compatible (byte) addresses. note: modulo addressing and bit-reversed addressing should not be enabled together. in the event that the user attempts to do this, bit-reversed address- ing will assume priority when active for the x wagu, and x wagu modulo address- ing will be disabled. however, modulo addressing will continue to function in the x ragu. b3 b2 b1 0 b2 b3 b4 0 bit locations swapped left-to-right around center of binary value bit-reversed address xb = 0x0008 for a 16 word bit-reversed buffer b7 b6 b5 b1 b7 b6 b5 b4 b11 b10 b9 b8 b11 b10 b9 b8 b15 b14 b13 b12 b15 b14 b13 b12 sequential address pivot point
dspic30f1010/202x ds70178a-page 48 advance information ? 2006 microchip technology inc. table 4-2: bit-reversed address sequence (16-entry) table 4-3: bit-reversed address modifier values for xbrev register normal address bit-reversed address a3 a2 a1 a0 decimal a3 a2 a1 a0 decimal 0000 0 0000 0 0001 1 1000 8 0010 2 0100 4 0011 3 1100 12 0100 4 0010 2 0101 5 1010 10 0110 6 0110 6 0111 7 1110 14 1000 8 0001 1 1001 9 1001 9 1010 10 0101 5 1011 11 1101 13 1100 12 0011 3 1101 13 1011 11 1110 14 0111 7 1111 15 1111 15 buffer size (words) xb<14:0> bit-reversed address modifier value (1) 32768 0x4000 16384 0x2000 8192 0x1000 4096 0x0800 2048 0x0400 1024 0x0200 512 0x0100 256 0x0080 128 0x0040 64 0x0020 32 0x0010 16 0x0008 80x0004 40x0002 20x0001 note 1: modifier values greater than 256 words exceed the data memory available on the dspic30f1010/202x device
? 2006 microchip technology inc. advance information ds70178a-page 49 dspic30f1010/202x 5.0 interrupts the dspic30f1010/202x device has up to 35 interrupt sources and 4 processor exceptions (traps), which must be arbitrated based on a priority scheme. the cpu is responsible for reading the interrupt vec- tor table (ivt) and transferring the address contained in the interrupt vector to the program counter (pc). the interrupt vector is transferred from the program data bus into the program counter, via a 24-bit wide multiplexer on the input of the program counter. the interrupt vector table and alternate interrupt vec- tor table (aivt) are placed near the beginning of pro- gram memory (0x000004). the ivt and aivt are shown in figure 5-1. the interrupt controller is responsible for pre- processing the interrupts and processor exceptions, prior to their being presented to the processor core. the peripheral interrupts and traps are enabled, priori- tized and controlled using centralized special function registers: ? ifs0<15:0>, ifs1<15:0>, ifs2<15:0> all interrupt request flags are maintained in these three registers. the flags are set by their respec- tive peripherals or external signals, and they are cleared via software. ? iec0<15:0>, iec1<15:0>, iec2<15:0> all interrupt enable control bits are maintained in these three registers. these control bits are used to individually enable interrupts from the peripherals or external signals. ? ipc0<15:0>... ipc11<7:0> the user-assignable priority level associated with each of these interrupts is held centrally in these twelve registers. ? ipl<3:0> the current cpu priority level is explic- itly stored in the ipl bits. ipl<3> is present in the corcon register, whereas ipl<2:0> are present in the status register (sr) in the processor core. ? intcon1<15:0>, intcon2<15:0> global interrupt control functions are derived from these two registers. intcon1 contains the con- trol and status flags for the processor exceptions. the intcon2 register controls the external inter- rupt request signal behavior and the use of the alternate vector table. all interrupt sources can be user assigned to one of 7 priority levels, 1 through 7, via the ipcx registers. each interrupt source is associated with an interrupt vector, as shown in figure 5-1. levels 7 and 1 repre- sent the highest and lowest maskable priorities, respectively. if the nstdis bit (intcon1<15>) is set, nesting of interrupts is prevented. thus, if an interrupt is currently being serviced, processing of a new interrupt is prevented, even if the new interrupt is of higher priority than the one currently being serviced. certain interrupts have specialized control bits for features like edge or level triggered interrupts, inter- rupt-on-change, etc. control of these features remains within the peripheral module that generates the interrupt. the disi instruction can be used to disable the processing of interrupts of priorities 6 and lower for a certain number of instructions, during which the disi bit (intcon2<14>) remains set. when an interrupt is serviced, the pc is loaded with the address stored in the vector location in program mem- ory that corresponds to the interrupt. there are 63 dif- ferent vectors within the ivt (refer to figure 5-1). these vectors are contained in locations 0x000004 through 0x0000fe of program memory (refer to figure 5-1). these locations contain 24-bit addresses, and, in order to preserve robustness, an address error trap will take place should the pc attempt to fetch any of these words during normal execution. this prevents execu- tion of random data as a result of accidentally decre- menting a pc into vector space, accidentally mapping a data space address into vector space, or the pc roll- ing over to 0x000000 after reaching the end of imple- mented program memory space. execution of a goto instruction to this vector space will also generate an address error trap. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). for more information on the device instruction set and programming, refer to the ? dspic30f/ 33f programmer?s reference manual? (ds70157). note: interrupt flag bits get set when an interrupt condition occurs, regardless of the state of its corresponding enable bit. user soft- ware should ensure the appropriate inter- rupt flag bits are clear prior to enabling an interrupt. note: assigning a priority level of 0 to an inter- rupt source is equivalent to disabling that interrupt. note: the ipl bits become read-only whenever the nstdis bit has been set to ? 1 ?.
dspic30f1010/202x ds70178a-page 50 advance information ? 2006 microchip technology inc. 5.1 interrupt priority the user-assignable interrupt priority (ip<2:0>) bits for each individual interrupt source are located in the least significant 3 bits of each nibble, within the ipcx register(s). bit 3 of each nibble is not used and is read as a ? 0 ?. these bits define the priority level assigned to a particular interrupt by the user. since more than one interrupt request source may be assigned to a specific user specified priority level, a means is provided to assign priority within a given level. this method is called ?natural order priority? and is final. natural order priority is determined by the position of an interrupt in the vector table, and only affects interrupt operation when multiple interrupts with the same user- assigned priority become pending at the same time. table 5-1 lists the interrupt numbers and interrupt sources for the dspic dsc devices and their associated vector numbers. the ability for the user to assign every interrupt to one of seven priority levels implies that the user can assign a very high overall priority level to an interrupt with a low natural order priority. the int0 (external interrupt 0) may be assigned to priority level 1, thus giving it a very low effective priority. table 5-1: dspic30f1010/202x interrupt vector table note: the user selectable priority levels start at 0, as the lowest priority, and level 7, as the highest priority. note 1: the natural order priority scheme has 0 as the highest priority and 53 as the lowest priority. 2: the natural order priority number is the same as the int number. int number vector number interrupt source highest natural order priority 0 8 int0 ? external interrupt 0 1 9 ic1 ? input capture 1 2 10 oc1 ? output compare 1 3 11 t1 ? timer 1 4 12 reserved 5 13 oc2 ? output compare 2 6 14 t2 ? timer 2 7 15 t3 ? timer 3 8 16 spi1 9 17 u1rx ? uart1 receiver 10 18 u1tx ? uart1 transmitter 11 19 adc ? adc convert done 12 20 nvm ? nvm write complete 13 21 si2c ? i 2 c? slave event 14 22 mi2c ? i 2 c master event 15 23 reserved 16 24 int1 ? external interrupt 1 17 25 int2 ? external interrupt 2 18 26 pwm special event trigger 19 27 pwm gen#1 20 28 pwm gen#2 21 29 pwm gen#3 22 30 pwm gen#4 23 31 reserved 24 32 reserved 25 33 reserved 26 34 reserved 27 35 icn ? input change notification 28 36 reserved 29 37 analog comparator 1 30 38 analog comparator 2 31 39 analog comparator 3 32 40 analog comparator 4 33 41 reserved 34 42 reserved 35 43 reserved 36 44 reserved 37 45 adc pair 0 conversion done 38 46 adc pair 1 conversion done 39 47 adc pair 2 conversion done 40 48 adc pair 3 conversion done 41 49 adc pair 4 conversion done 42 50 adc pair 5 conversion done 43 51 reserved 44 52 reserved 45-53 53-61 reserved lowest natural order priority
? 2006 microchip technology inc. advance information ds70178a-page 51 dspic30f1010/202x 5.2 reset sequence a reset is not a true exception, because the interrupt controller is not involved in the reset process. the pro- cessor initializes its registers in response to a reset, which forces the pc to zero. the processor then begins program execution at location 0x000000. a goto instruction is stored in the first program memory loca- tion, immediately followed by the address target for the goto instruction. the processor executes the goto to the specified address and then begins operation at the specified target (start) address. 5.2.1 reset sources in addition to external reset and power-on reset (por), there are 6 sources of error conditions which ?trap? to the reset vector. ? watchdog time-out: the watchdog has timed out, indicating that the processor is no longer executing the correct flow of code. ? uninitialized w register trap: an attempt to use an uninitialized w register as an address pointer will cause a reset. ? illegal instruction trap: attempted execution of any unused opcodes will result in an illegal instruction trap. note that a fetch of an illegal instruction does not result in an illegal instruction trap if that instruction is flushed prior to execution due to a flow change. ? trap lockout: occurrence of multiple trap conditions simultaneously will cause a reset. 5.3 traps traps can be considered as non-maskable interrupts indicating a software or hardware error, which adhere to a predefined priority as shown in figure 5-1. they are intended to provide the user a means to correct erroneous operation during debug and when operating within the application. note that many of these trap conditions can only be detected when they occur. consequently, the question- able instruction is allowed to complete prior to trap exception processing. if the user chooses to recover from the error, the result of the erroneous action that caused the trap may have to be corrected. there are 8 fixed priority levels for traps: level 8 through level 15, which implies that the ipl3 is always set during processing of a trap. if the user is not currently executing a trap, and he sets the ipl<3:0> bits to a value of ? 0111 ? (level 7), then all interrupts are disabled, but traps can still be processed. 5.3.1 trap sources the following traps are provided with increasing prior- ity. however, since all traps can be nested, priority has little effect. math error trap: the math error trap executes under the following four circumstances: 1. should an attempt be made to divide by zero, the divide operation will be aborted on a cycle boundary and the trap taken. 2. if enabled, a math error trap will be taken when an arithmetic operation on either accumulator a or b causes an overflow from bit 31 and the accumulator guard bits are not utilized. 3. if enabled, a math error trap will be taken when an arithmetic operation on either accumulator a or b causes a catastrophic overflow from bit 39 and all saturation is disabled. 4. if the shift amount specified in a shift instruction is greater than the maximum allowed shift amount, a trap will occur. note: if the user does not intend to take correc- tive action in the event of a trap error con- dition, these vectors must be loaded with the address of a default handler that sim- ply contains the reset instruction. if, on the other hand, one of the vectors contain- ing an invalid address is called, an address error trap is generated.
dspic30f1010/202x ds70178a-page 52 advance information ? 2006 microchip technology inc. address error trap: this trap is initiated when any of the following circumstances occurs: 1. a misaligned data word access is attempted. 2. a data fetch from our unimplemented data memory location is attempted. 3. a data access of an unimplemented program memory location is attempted. 4. an instruction fetch from vector space is attempted. 5. execution of a ? bra #litera l? instruction or a ? goto #literal ? instruction, where literal is an unimplemented program memory address. 6. executing instructions after modifying the pc to point to unimplemented program memory addresses. the pc may be modified by loading a value into the stack and executing a return instruction. stack error trap: this trap is initiated under the following conditions: 1. the stack pointer is loaded with a value which is greater than the (user programmable) limit value written into the splim register (stack overflow). 2. the stack pointer is loaded with a value which is less than 0x0800 (simple stack underflow). oscillator fail trap: this trap is initiated if the external oscillator fails and operation becomes reliant on an internal rc backup. 5.3.2 hard and soft traps it is possible that multiple traps can become active within the same cycle (e.g., a misaligned word stack write to an overflowed address). in such a case, the fixed priority shown in figure 5-1 is implemented, which may require the user to check if other traps are pending, in order to completely correct the fault. ?soft? traps include exceptions of priority level 8 through level 11, inclusive. the arithmetic error trap (level 11) falls into this category of traps. ?hard? traps include exceptions of priority level 12 through level 15, inclusive. the address error (level 12), stack error (level 13) and oscillator error (level 14) traps fall into this category. each hard trap that occurs must be acknowledged before code execution of any type may continue. if a lower priority hard trap occurs while a higher priority trap is pending, acknowledged, or is being processed, a hard trap conflict will occur. the device is automatically reset in a hard trap conflict condition. the trapr status bit (rcon<15>) is set when the reset occurs, so that the condition may be detected in software. figure 5-1: trap vectors note: in the mac class of instructions, wherein the data space is split into x and y data space, unimplemented x space includes all of y space, and unimplemented y space includes all of x space. address error trap vector oscillator fail trap vector stack error trap vector reserved vector math error trap vector reserved oscillator fail trap vector address error trap vector reserved vector reserved vector interrupt 0 vector interrupt 1 vector ? ? ? interrupt 52 vector interrupt 53 vector math error trap vector decreasing priority 0x000000 0x000014 reserved stack error trap vector reserved vector reserved vector interrupt 0 vector interrupt 1 vector ? ? ? interrupt 52 vector interrupt 53 vector ivt aivt 0x000080 0x00007e 0x0000fe reserved 0x000094 reset - goto instruction reset - goto address 0x000002 reserved 0x000082 0x000084 0x000004 reserved vector
? 2006 microchip technology inc. advance information ds70178a-page 53 dspic30f1010/202x 5.4 interrupt sequence all interrupt event flags are sampled in the beginning of each instruction cycle by the ifsx registers. a pending interrupt request (irq) is indicated by the flag bit being equal to a ? 1 ? in an ifsx register. the irq will cause an interrupt to occur if the corresponding bit in the interrupt enable (iecx) register is set. for the remainder of the instruction cycle, the priorities of all pending interrupt requests are evaluated. if there is a pending irq with a priority level greater than the current processor priority level in the ipl bits, the processor will be interrupted. the processor then stacks the current program counter and the low byte of the processor status register (srl), as shown in figure 5-2. the low byte of the status register contains the processor priority level at the time, prior to the beginning of the interrupt cycle. the processor then loads the priority level for this interrupt into the status register. this action will disable all lower priority interrupts until the completion of the interrupt service routine (isr). figure 5-2: interrupt stack frame the retfie (return from interrupt) instruction will unstack the program counter and status registers to return the processor to its state prior to the interrupt sequence. 5.5 alternate vector table in program memory, the ivt is followed by the aivt, as shown in figure 5-1. access to the alternate vector table is provided by the altivt bit in the intcon2 register. if the altivt bit is set, all interrupt and excep- tion processes will use the alternate vectors instead of the default vectors. the alternate vectors are organized in the same manner as the default vectors. the aivt supports emulation and debugging efforts by providing a means to switch between an application and a sup- port environment, without requiring the interrupt vec- tors to be reprogrammed. this feature also enables switching between applications for evaluation of different software algorithms at run time. if the aivt is not required, the program memory allo- cated to the aivt may be used for other purposes. aivt is not a protected section and may be freely programmed by the user. 5.6 fast context saving a context saving option is available using shadow reg- isters. shadow registers are provided for the dc, n, ov, z and c bits in sr, and the registers w0 through w3. the shadows are only one level deep. the shadow registers are accessible using the push.s and pop.s instructions only. when the processor vectors to an interrupt, the push.s instruction can be used to store the current value of the aforementioned registers into their respective shadow registers. if an isr of a certain priority uses the push.s and pop.s instructions for fast context saving, then a higher priority isr should not include the same instruc- tions. users must save the key registers in software during a lower priority interrupt, if the higher priority isr uses fast context saving. 5.7 external interrupt requests the interrupt controller supports five external interrupt request signals, int0-int4. these inputs are edge sensitive; they require a low-to-high or a high-to-low transition to generate an interrupt request. the intcon2 register has five bits, int0ep-int4ep, that select the polarity of the edge detection circuitry. 5.8 wake-up from sleep and idle the interrupt controller may be used to wake-up the processor from either sleep or idle modes, if sleep or idle mode is active when the interrupt is generated. if an enabled interrupt request of sufficient priority is received by the interrupt controller, then the standard interrupt request is presented to the processor. at the same time, the processor will wake-up from sleep or idle and begin execution of the interrupt service routine needed to process the interrupt request. note 1: the user can always lower the priority level by writing a new value into sr. the interrupt service routine must clear the interrupt flag bits in the ifsx register before lowering the processor interrupt priority, in order to avoid recursive interrupts. 2: the ipl3 bit (corcon<3>) is always clear when interrupts are being pro- cessed. it is set only during execution of traps. 0 15 w15 (before call ) w15 (after call ) stack grows towards higher address push : [w15++] pop : [--w15] 0x0000 pc<15:0> srl ipl3 pc<22:16>
dspic30f1010/202x ds70178a-page 54 advance information ? 2006 microchip technology inc. register 5-1: intcon1: interrupt control register 1 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 nstdis ovaerr ovberr covaerr covberr ovate ovbte covte bit 15 bit 8 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 sftacerr div0err ? matherr addrerr stkerr oscfail ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 nstdis: interrupt nesting disable bit 1 = interrupt nesting is disabled 0 = interrupt nesting is enabled bit 14 ovaerr: accumulator a overflow trap flag bit 1 = trap was caused by overflow of accumulator a 0 = trap was not caused by overflow of accumulator a bit 13 ovberr: accumulator b overflow trap flag bit 1 = trap was caused by overflow of accumulator b 0 = trap was not caused by overflow of accumulator b bit 12 covaerr: accumulator a catastrophic overflow trap enable bit 1 = trap was caused by catastrophic overflow of accumulator a 0 = trap was not caused by catastrophic overflow of accumulator a bit 11 covberr: accumulator b catastrophic overflow trap enable bit 1 = trap was caused by catastrophic overflow of accumulator b 0 = trap was not caused by catastrophic overflow of accumulator b bit 10 ovate: accumulator a overflow trap enable bit 1 = trap overflow of accumulator a 0 = trap disabled bit 9 ovbte: accumulator b overflow trap enable bit 1 = trap overflow of accumulator b 0 = trap disabled bit 8 covte: catastrophic overflow trap enable bit 1 = trap on catastrophic overflow of accumulator a or b enabled 0 = trap disabled bit 7 sftacerr: shift accumulator error status bit 1 = math error trap was caused by an invalid accumulator shift 0 = math error trap was not caused by an invalid accumulator shift bit 6 div0err: arithmetic error status bit 1 = math error trap was caused by a divided by zero 0 = math error trap was not caused by an invalid accumulator shift bit 5 unimplemented: read as ? 0 ? bit 4 matherr: arithmetic error status bit 1 = overflow trap has occurred 0 = overflow trap has not occurred bit 3 addrerr: address error trap status bit 1 = address error trap has occurred 0 = address error trap has not occurred
? 2006 microchip technology inc. advance information ds70178a-page 55 dspic30f1010/202x bit 2 stkerr: stack error trap status bit 1 = stack error trap has occurred 0 = stack error trap has not occurred bit 1 oscfail: oscillator failure trap status bit 1 = oscillator failure trap has occurred 0 = oscillator failure trap has not occurred bit 0 unimplemented: read as ? 0 ? register 5-1: intcon1: interrupt control register 1 (continued)
dspic30f1010/202x ds70178a-page 56 advance information ? 2006 microchip technology inc. register 5-2: intcon2: interrupt control register 2 r/w-0 r-0 u-0 u-0 u-0 u-0 u-0 u-0 altivt disi ? ? ? ? ? ? bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 ? ? ? ? ? int2ep int1ep int0ep bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 altivt: enable alternate interrupt vector table bit 1 = use alternate vector table 0 = use standard (default) vector table bit 14 disi: disi instruction status bit 1 = disi instruction is active 0 = disi instruction is not active bit 13-3 unimplemented: read as ? 0 ? bit 2 int2ep: external interrupt 2 edge detect polarity select bit 1 = interrupt on negative edge 0 = interrupt on positive edge bit 1 int1ep: external interrupt 1 edge detect polarity select bit 1 = interrupt on negative edge 0 = interrupt on positive edge bit 0 int0ep: external interrupt 0 edge detect polarity select bit 1 = interrupt on negative edge 0 = interrupt on positive edge
? 2006 microchip technology inc. advance information ds70178a-page 57 dspic30f1010/202x register 5-3: ifs0: interrupt flag status register 0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? mi2cif si2cif nvmif adif u1txif u1rxif spi1if bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 t3if t2if oc2if ? t1if oc1if ic1if int0if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14 mi2cif: i 2 c master events interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 13 si2cif: i 2 c slave events interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 12 nvmif: nonvolatile memory interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 11 adif: adc conversion complete interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 10 u1txif: uart1 transmitter interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 9 u1rxif: uart1 receiver interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 8 spi1if: spi1 event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 7 t3if: timer3 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 6 t2if: timer2 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 5 oc2if: output compare channel 2 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 4 unimplemented: read as ? 0 ? bit 3 t1if: timer1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred
dspic30f1010/202x ds70178a-page 58 advance information ? 2006 microchip technology inc. bit 2 oc1if: output compare channel 1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 1 ic1if: input capture channel 1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 0 int0if: external interrupt 0 flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred register 5-3: ifs0: interrupt flag status register 0 (continued)
? 2006 microchip technology inc. advance information ds70178a-page 59 dspic30f1010/202x register 5-4: ifs1: interrupt flag status register 1 r/w-0 r/w-0 r/w-0 u-0 r/w-0 u-0 u-0 u-0 ac3if ac2if ac1if ? cnif ? ? ? bit 15 bit 8 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? pwm4if pwm3if pwm2if pwm1if psemif int2if int1if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 ac3if: analog comparator #3 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 14 ac2if: analog comparator #2 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 13 ac1if: analog comparator #1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 12 unimplemented: read as ? 0 ? bit 11 cnif: input change notification interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 10 -7 unimplemented: read as ? 0 ? bit 6 pwm4if: pulse width modulation generator #4 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 5 pwm3if: pulse width modulation generator #3 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 4 pwm2if: pulse width modulation generator #2 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 3 pwm1if: pulse width modulation generator #1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 2 psemif: pwm special event match interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 1 int2if: external interrupt 2 flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 0 int1if: external interrupt 1 flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred
dspic30f1010/202x ds70178a-page 60 advance information ? 2006 microchip technology inc. register 5-5: ifs2: interrupt flag status register 2 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-00 r/w-0 ? ? ? ? ? adcp5if adcp4if adcp3if bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 r/w-0 adcp2if adcp1if adcp0if ? ? ? ?ac4if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as ? 0 ? bit 10 adcp5if: adc pair 5 conversion done interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 9 adcp4if: adc pair 4 conversion done interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 8 adcp3if: adc pair 3 conversion done interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 7 adcp2if: adc pair 2 conversion done interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 6 adcp1if: adc pair 1 conversion done interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 5 adcp0if: adc pair 0 conversion done interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 4-1 unimplemented: read as ? 0 ? bit 0 ac4if: analog comparator #4 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred
? 2006 microchip technology inc. advance information ds70178a-page 61 dspic30f1010/202x register 5-6: iec0: interrupt enable control register 0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? mi2cie si2cie nvmie adie u1txie u1rxie spi1ie bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 t3ie t2ie oc2ie ? t1ie oc1ie ic1ie int0ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14 mi2cie: i 2 c master events interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 13 si2cie: i 2 c slave events interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 12 nvmie: nonvolatile memory interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 11 adie: adc conversion complete interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 10 u1txie: uart1 transmitter interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 9 u1rxie: uart1 receiver interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 8 spi1ie: spi1 event interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 7 t3ie: timer3 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 6 t2ie: timer2 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 5 oc2ie: output compare channel 2 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 4 unimplemented: read as ? 0 ? bit 3 t1ie: timer1 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled
dspic30f1010/202x ds70178a-page 62 advance information ? 2006 microchip technology inc. bit 2 oc1ie: output compare channel 1 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 1 ic1ie: input capture channel 1 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 0 int0ie: external interrupt 0 enable bit 1 = interrupt request enabled 0 = interrupt request not enabled register 5-6: iec0: interrupt enable control register 0 (continued)
? 2006 microchip technology inc. advance information ds70178a-page 63 dspic30f1010/202x register 5-7: iec1: interrupt enable control register 1 r/w-0 r/w-0 r/w-0 u-0 r/w-0 u-0 u-0 u-0 ac3ie ac2ie ac1ie ? cnie ? ? ? bit 15 bit 8 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? pwm4ie pwm3ie pwm2ie pwm1ie psemie int2ie int1ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 ac3ie: analog comparator #3 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 14 ac2ie: analog comparator #2 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 13 ac1ie: analog comparator #1 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 12 unimplemented: read as ? 0 ? bit 11 cnie: input change notification interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 10 -7 unimplemented: read as ? 0 ? bit 6 pwm4ie: pulse width modulation generator #4 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 5 pwm3ie: pulse width modulation generator #3 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 4 pwm2ie: pulse width modulation generator #2 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 3 pwm1ie: pulse width modulation generator #1 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 2 psemie: pwm special event match interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 1 int2ie: external interrupt 2 enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 0 int1ie: external interrupt 1 enable bit 1 = interrupt request enabled 0 = interrupt request not enabled
dspic30f1010/202x ds70178a-page 64 advance information ? 2006 microchip technology inc. register 5-8: iec2: interrupt enable control register 2 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 ? ? ? ? ? adcp5ie adcp4ie adcp3ie bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 r/w-0 adcp2ie adcp1ie adcp0ie ? ? ? ?ac4ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 -11 unimplemented: read as ? 0 ? bit 10 adcp5ie: adc pair 5 conversion done interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 9 adcp5ie: adc pair 5 conversion done interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 8 adcp4ie: adc pair 4 conversion done interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 7 adcp3ie: adc pair 3 conversion done interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 8 adcp2ie: adc pair 2 conversion done interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 7 adcp1ie: adc pair 1 conversion done interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 6 adcp0ie: adc pair 0 conversion done interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled bit 4 -1 unimplemented: read as ? 0 ? bit 0 ac4ie: analog comparator #4 interrupt enable bit 1 = interrupt request enabled 0 = interrupt request not enabled
? 2006 microchip technology inc. advance information ds70178a-page 65 dspic30f1010/202x register 5-9: ipc0: interrupt priority control register 0 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? t1ip<2:0> ? oc1ip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? ic1ip<2:0> ? int0ip<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14-12 t1ip<2:0>: timer1 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as ? 0 ? bit 10-8 oc1ip<2:0>: output compare channel 1 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6-4 ic1ip<2:0>: input capture channel 1 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as ? 0 ? bit 2-0 int0ip<2:0>: external interrupt 0 priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled
dspic30f1010/202x ds70178a-page 66 advance information ? 2006 microchip technology inc. register 5-10: ipc1: interrupt priority control register 1 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? t3ip<2:0> ? t2ip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ?oc2ip<2:0> ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14-12 t3ip<2:0>: timer3 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as ? 0 ? bit 10-8 t2ip<2:0>: timer2 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6-4 oc2ip<2:0>: output compare channel 2 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3-0 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 67 dspic30f1010/202x register 5-11: ipc2: interrupt priority control register 2 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? adip<2:0> ? u1txip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? u1rxip<2:0> ? spi1ip<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14-12 adip<2:0>: adc conversion complete interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as ? 0 ? bit 10-8 u1txip<2:0>: uart1 transmitter interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6-4 u1rxip<2:0>: uart1 receiver interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as ? 0 ? bit 2-0 spi1ip<2:0>: spi1 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled
dspic30f1010/202x ds70178a-page 68 advance information ? 2006 microchip technology inc. register 5-12: ipc3: interrupt control register 3 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 ? ? ? ? ?mi2cip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ?si2cip<2:0> ? nvmip<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as ? 0 ? bit 10-8 mi2cip<2:0>: i 2 c master events interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6-4 si2cip<2:0>: i 2 c slave events interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as ? 0 ? bit 2-0 nvmip<2:0>: nonvolatile memory interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled
? 2006 microchip technology inc. advance information ds70178a-page 69 dspic30f1010/202x register 5-13: ipc4: interrupt priority control register 4 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? pwm1ip<2:0> ? psemip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? int2ip<2:0> ? int1ip<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14-12 pwm1ip<2:0>: pwm generator #1 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as ? 0 ? bit 10-8 psemip<2:0>: pwm special event match priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6-4 int2ip<2:0>: external interrupt 2 priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as ? 0 ? bit 2-0 int1ip<2:0>: external interrupt 1 priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled
dspic30f1010/202x ds70178a-page 70 advance information ? 2006 microchip technology inc. register 5-14: ipc5: interrupt priority control register 5 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 ? ? ? ? ? pwm4ip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? pwm3ip<2:0> ? pwm2ip<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as ? 0 ? bit 10-8 pwm4ip<2:0>: pwm generator #4 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6-4 pwm3ip<2:0>: pwm generator #3 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as ? 0 ? bit 2-0 pwm2ip<2:0>: pwm generator #2 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled
? 2006 microchip technology inc. advance information ds70178a-page 71 dspic30f1010/202x register 5-15: ipc6: interrupt priority control register 6 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ?cnip<2:0> ? ? ? ? bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 ? ? ? ? ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14-12 cnip<2:0>: change notification interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11-0 unimplemented: read as ? 0 ?
dspic30f1010/202x ds70178a-page 72 advance information ? 2006 microchip technology inc. register 5-16: ipc7: interrupt priority control register 7 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? ac3ip<2:0> ? ac2ip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ? ac1ip<2:0> ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14-12 ac3ip<2:0>: analog comparator 3 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as ? 0 ? bit 10-8 ac2ip<2:0>: analog comparator 2 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6-4 ac1ip<2:0>: analog comparator 1 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3-0 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 73 dspic30f1010/202x register 5-17: ipc8: interrupt priority control register 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 ? ? ? ? ? ? ? ? bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 ? ? ? ? ? ac4ip<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-3 unimplemented: read as ? 0 ? bit 2-0 ac4ip<2:0>: analog comparator 4 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled
dspic30f1010/202x ds70178a-page 74 advance information ? 2006 microchip technology inc. register 5-18: ipc9: interrupt priority control register 9 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? adcp2ip<2:0> ? adcp1ip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ? adcp0ip<2:0> ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? bit 14 - 12 adcp2ip<2:0>: adc pair 2 conversion done interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as ? 0 ? bit 10 - 8 adcp1ip<2:0>: adc pair 1 conversion done interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 6 - 4 adcp0ip<2:0>: adc pair 0 conversion done interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 - 0 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 75 dspic30f1010/202x register 5-19: ipc10: interrupt priority control register 10 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 ? ? ? ? ? adcp5ip<2:0> bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ? adcp4ip<2:0> ? adcp3ip<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 -10 unimplemented: read as ? 0 ? bit 10 - 8 adcp5ip<2:0>: adc pair 5 conversion done interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as ? 0 ? bit 10 - 8 adcp4ip<2:0>: adc pair 4 conversion done interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as ? 0 ? bit 2 - 0 adcp3ip<2:0>: adc pair 3 conversion done interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) ? ? ? 001 = interrupt is priority 1 000 = interrupt source is disabled
? 2006 microchip technology inc. advance information ds70178a-page 76 dspic30f1010/202x table 5-2: interrupt controller register map sfr name adr bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state intcon1 0080 nstdis ovaerr ovberr covaerr covberr ovate ovbte covte sftacerr div0err ?matherr addrerr stkerr oscfail ? 0000 0000 0000 0000 intcon2 0082 altivt disi ? ? ? ? ? ? ? ? ? ? ? int2ep int1ep int0ep 0000 0000 0000 0000 ifs0 0084 ? mi2cif si2cif nvmif adif u1txif u1rxif spi1if t3if t2if oc2if ? t1if oc1if ic1if int0if 0000 0000 0000 0000 ifs1 0086 ac3if ac2if ac1if ? cnif ? ? ? ? pwm4if pwm3if pwm2if pwm1if psemif int2if int1if 0000 0000 0000 0000 ifs2 0088 ? ? ? ? ? adcp5if adcp4if adcp3if adcp2if adcp41f adcp0if ? ? ? ?ac4if 0000 0000 0000 0000 iec0 0094 ? mi2cie si2cie nvmie adie u1txie u1rxie spi1ie t3ie t2ie oc2ie ? t1ie oc1ie ic1ie int0ie 0000 0000 0000 0000 iec1 0096 ac3ie ac2ie ac1ie ? cnie ? ? ? ? pwm4ie pwm3ie pwm2ie pwm1ie psemie int2ie int1ie 0000 0000 0000 0000 iec2 0098 ? ? ? ? ? adcp5ie adcp4ie adcp3ie adcp2ie adcp1ie adcp0ie ? ? ? ?ac4ie 0000 0000 0000 0000 ipc0 00a4 ? t1ip<2:0> ? oc1ip<2:0> ? ic1ip<2:0> ? int0ip<2:0> 0100 0100 0100 0100 ipc1 00a6 ? t31p<2:0> ? t2ip<2:0> ? oc2ip<2:0> ? ? ? ? 0100 0100 0100 0000 ipc2 00a8 ? adip<2:0> ? u1txip<2:0> ? u1rxip<2:0> ? spi1ip<2:0> 0100 0100 0100 0100 ipc3 00aa ? ? ? ? ?mi2cip<2:0> ? si2cip<2:0> ? nvmip<2:0> 0000 0100 0100 0100 ipc4 00ac ? pwm1ip<2:0> ?psemip<2:0> ? int2ip<2:0> ? int1ip<2:0> 0100 0100 0100 0100 ipc5 00ae ? ? ? ? ? pwm4ip<2:0> ? pwm3ip<2:0> ? pwm2ip<2:0> 0000 0100 0100 0100 ipc6 00b0 ? cnip<2:0> ? ? ? ? ? ? ? ? ? ? ? ? 0100 0000 0000 0000 ipc7 00b2 ? ac3ip<2:0> ?ac2ip<2:0> ? ac1ip<2:0> ? ? ? ? 0100 0100 0100 0000 ipc8 00b4 ? ? ? ? ? ? ? ? ? ? ? ? ? ac4ip<2:0> 0000 0000 0000 0100 ipc9 00b6 ? adcp2ip<2:0> ? adcp1ip<2:0> ? adcp0ip<2:0> ? ? ? ? 0100 0100 0100 0000 ipc10 00b8 ? ? ? ? ? adcp5ip<2:0> ? adcp4ip<2:0> ? adcp3ip<2:0> 0000 0100 0100 0100 note: refer to the ? dspic30f family reference manual ? (ds70046) for descriptions of register bit fields.
? 2006 microchip technology inc. advance information ds70178a-page 77 dspic30f1010/202x 6.0 i/o ports all of the device pins (except v dd , v ss , mclr and osc1/clki) are shared between the peripherals and the parallel i/o ports. all i/o input ports feature schmitt trigger inputs for improved noise immunity. 6.1 parallel i/o (pio) ports when a peripheral is enabled and the peripheral is actively driving an associated pin, the use of the pin as a general purpose output pin is disabled. the i/o pin may be read, but the output driver for the parallel port bit will be disabled. if a peripheral is enabled, but the peripheral is not actively driving a pin, that pin may be driven by a port. all port pins have three registers directly associated with the operation of the port pin. the data direction register (trisx) determines whether the pin is an input or an output. if the data direction bit is a ? 1 ?, then the pin is an input. all port pins are defined as inputs after a reset. reads from the latch (latx), read the latch. writes to the latch, write the latch (latx). reads from the port (portx), read the port pins, and writes to the port pins, write the latch (latx). any bit and its associated data and control registers that are not valid for a particular device will be disabled. that means the corresponding latx and trisx registers and the port pin will read as zeros. when a pin is shared with another peripheral or func- tion that is defined as an input only, it is nevertheless regarded as a dedicated port because there is no other competing source of outputs. a parallel i/o (pio) port that shares a pin with a periph- eral is, in general, subservient to the peripheral. the peripheral?s output buffer data and control signals are provided to a pair of multiplexers. the multiplexers select whether the peripheral or the associated port has ownership of the output data and control signals of the i/o pad cell. figure 6-1 shows how ports are shared with other peripherals, and the associated i/o cell (pad) to which they are connected. table 6-1 and table 6-2 show the register formats for the shared ports, porta through portf, for the dspic30f1010/2020 and the dspic30f2023 device, respectively. figure 6-1: block diagram of a shared port structure note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual? (ds70046). q d ck wr lat + tris latch i/o pad wr port data bus q d ck data latch read lat read port read tris 1 0 1 0 wr tris peripheral output data output enable peripheral input data i/o cell peripheral module peripheral output enable pio module output multiplexers output data input data peripheral module enable
dspic30f1010/202x ds70178a-page 78 advance information ? 2006 microchip technology inc. 6.2 configuring analog port pins the use of the adpcfg and tris registers control the operation of the a/d port pins. the port pins that are desired as analog inputs must have their correspond- ing tris bit set (input). if the tris bit is cleared (output), the digital output level (v oh or v ol ) will be converted. when reading the port register, all pins configured as analog input channel will read as cleared (a low level). pins configured as digital inputs will not convert an ana- log input. analog levels on any pin that is defined as a digital input (including the anx pins), may cause the input buffer to consume current that exceeds the device specifications. 6.2.1 i/o port write/read timing one instruction cycle is required between a port direction change or port write operation and a read operation of the same port. typically this instruction would be a nop . example 6-1: port write/read example 6.3 input change notification the input change notification function of the i/o ports allows the dspic30f1010/202x devices to generate interrupt requests to the processor in response to a change-of-state on selected input pins. this feature is capable of detecting input change-of-states even in sleep mode, when the clocks are disabled. there are 8 external signals (cn0 through cn7) that can be selected (enabled) for generating an interrupt request on a change-of-state. there are two control registers associated with the cn module. the cnen1 register contain the cn interrupt enable (cnxie) control bits for each of the cn input pins. setting any of these bits enables a cn interrupt for the corresponding pins. each cn pin also has a weak pull-up connected to it. the pull-ups act as a current source that is connected to the pin and eliminate the need for external resistors when push button or keypad devices are connected. the pull-ups are enabled separately using the cnpu1 register, which contain the weak pull-up enable (cnx- pue) bits for each of the cn pins. setting any of the control bits enables the weak pull-ups for the corre- sponding pins. mov 0xff00, w0; configure portb<15:8> ; as inputs mov w0, trisbb; and portb<7:0> as outputs nop ; delay 1 cycle btss portb, #13; next instruction note: pull-ups on change notification pins should always be disabled whenever the port pin is configured as a digital output.
? 2006 microchip technology inc. advance information ds70178a-page 79 dspic30f1010/202x note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields. table 6-1: dspic30f1010/2020 port register map sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state trisa 02c0 ? ? ? ? ? ?tris9 ? ? ? ? ? ? ? ? ? 0000 0010 0000 0000 porta 02c2 ? ? ? ? ? ?ra9 ? ? ? ? ? ? ? ? ? 0000 0000 0000 0000 lata 02c4 ? ? ? ? ? ?lat9 ? ? ? ? ? ? ? ? ? 0000 0000 0000 0000 trisb 02c6 ? ? ? ? ? ? ? ? trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 0000 0000 0011 1111 portb 02c8 ? ? ? ? ? ? ? ? rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 0000 0000 0000 0000 latb 02ca ? ? ? ? ? ? ? ? latb7 latb6 latb5 latb4 latb3 latb2 latb1 latb0 0000 0000 0000 0000 trisd 02d2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?trisd0 0000 0000 0000 0101 portd 02d4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? rd0 0000 0000 0000 0000 latd 02d6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?latd0 0000 0000 0000 0000 trise 02d8 ? ? ? ? ? ? ? ? trse7 trse6 trise5 trise4 trise3 trise2 trise1 trise0 0000 0000 1111 1111 porte 02da ? ? ? ? ? ? ? ? re7 re6 re5 re4 re3 re2 re1 re0 0000 0000 0000 0000 late 02dc ? ? ? ? ? ? ? ? late7 late6 late5 late4 late3 late2 late1 late0 0000 0000 0000 0000 trisf 02de ? ? ? ? ? ? ? trisf8 trisf7 trisf6 ? ? ? ? ? ? 0000 0001 1100 0000 portf 02e0 ? ? ? ? ? ? ? rf8 rf7 rf6 ? ? ? ? ? ? 0000 0000 0000 0000 latf 02e2 ? ? ? ? ? ? ? latf8 latf7 latf6 ? ? ? ? ? ? 0000 0000 0000 0000
dspic30f1010/202x ds70178a-page 80 advance information ? 2006 microchip technology inc. table 6-2: dspic30f2023 port register map note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields. table 6-3: dspic30f1010/202x input change notification register map note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields. sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state trisa 02c0 ? ? ? ? trisa11 trisa10 tris9 trisa8 ? ? ? ? ? ? ?trisa0 0000 1111 0000 0001 porta 02c2 ? ? ? ? ra11 ra10 ra9 ra8 ? ? ? ? ? ? ?ra0 0000 0000 0000 0000 lata 02c4 ? ? ? ? lata11 lata10 lata9 lata8 ? ? ? ? ? ? ?lata0 0000 0000 0000 0000 trisb 02c6 ? ? ? ? trisb11 trisb10 trisb9 trisb8 trisb7 tris6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 0000 1111 1111 1111 portb 02c8 ? ? ? ? rb11 rb10 rb9 rb8 rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 0000 0000 0000 0000 latb 02ca ? ? ? ? latb11 latb10 latb9 latb8 latb7 latb6 latb5 latb4 latb3 latb2 latb1 latb0 0000 0000 0000 0000 trisd 02d2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? trisd1 ? 0000 0000 0000 0010 portd 02d4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? rd1 ? 0000 0000 0000 0000 latd 02d6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? latd1 ? 0000 0000 0000 0000 trise 02d8 ? ? ? ? ? ? ? ? trse7 trse6 trise5 trise4 trise3 trise2 trise1 trise0 0000 0000 1111 1111 porte 02da ? ? ? ? ? ? ? ?re7re6 re5 re4 re3 re2 re1 re0 0000 0000 0000 0000 late 02dc ? ? ? ? ? ? ? ?late7late6 late5 late4 late3 late2 late1 late0 0000 0000 0000 0000 trisf 02de trisf15 trisf14 ? ? ? ? ? trisf8 trisf7 trisf6 ? ? trisf3 trisf2 ? ? 1100 0001 1100 1100 portf 02e0 rf15 rf14 ? ? ? ? ?rf8rf7rf6 ? ? rf3 rf2 ? ? 0000 0000 0000 0000 latf 02e2 latf15 latf14 ? ? ? ? ? latf8 latf7 latf6 ? ? latf3 latf2 ? ? 0000 0000 0000 0000 trisg 02e4 ? ? ? ? ? ? ? ? ? ? ? ? trisg3 trisg2 ? ? 0000 0000 0000 1100 portg 02e6 ? ? ? ? ? ? ? ? ? ? ? ? rg3 rg2 ? ? 0000 0000 0000 0000 latg 02e8 ? ? ? ? ? ? ? ? ? ? ? ? latg3 latg2 ? ? 0000 0000 0000 0000 sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state cnen1 0060 ? ? ? ? ? ? ? ? cn7ie cn6ie cn5ie cn4ie cn3ie cn2ie cn1ie cn0ie 0000 1111 0000 0001 cnpu1 0064 ? ? ? ? ? ? ? ? cn7pue cn6pue cn5pue cn4pue cn3pue cn2pue cn1pue cn0pue 0000 0000 0000 0000
? 2006 microchip technology inc. advance information ds70178a-page 81 dspic30f1010/202x 7.0 flash program memory the dspic30f family of devices contains internal program flash memory for executing user code. there are two methods by which the user can program this memory: 1. in-circuit serial programming? (icsp?) programming capability 2. run time self-programming (rtsp) 7.1 in-circuit serial programming (icsp) dspic30f devices can be serially programmed while in the end application circuit. this is simply done with two lines for programming clock and programming data (which are named pgc and pgd respectively), and three other lines for power (v dd ), ground (v ss ) and master clear (mclr ). this allows customers to manu- facture boards with unprogrammed devices, and then program the microcontroller just before shipping the product. this also allows the most recent firmware or a custom firmware to be programmed. 7.2 run time self-programming (rtsp) rtsp is accomplished using tblrd (table read) and tblwt (table write) instructions. with rtsp, the user may erase program memory 32 instructions (96 bytes) at a time and can write program memory data 32 instructions (96 bytes) at a time. 7.3 table instruction operation summary the tblrdl and the tblwtl instructions are used to read or write to bits <15:0> of program memory. tblrdl and tblwtl can access program memory in word or byte mode. the tblrdh and tblwth instructions are used to read or write to bits<23:16> of program memory. tblrdh and tblwth can access program memory in word or byte mode. a 24-bit program memory address is formed using bits<7:0> of the tblpag register and the effective address (ea) from a w regist er specified in the table instruction, as shown in figure 7-1. figure 7-1: addressing for table and nvm registers note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). for more information on the device instruction set and programming, refer to the ? dspic30f/ 33f programmer?s reference manual? (ds70157). 0 program counter 24 bits nvmadru reg 8 bits 16 bits program using tblpag reg 8 bits working reg ea 16 bits using byte 24-bit ea 1/0 0 1/0 select ta b l e instruction nvmadr addressing counter using nvmadr reg ea user/configuration space select
dspic30f1010/202x ds70178a-page 82 advance information ? 2006 microchip technology inc. 7.4 rtsp operation the dspic30f flash program memory is organized into rows and panels. each row consists of 32 instruc- tions, or 96 bytes. each panel consists of 128 rows, or 4k x 24 instructions. rtsp allows the user to erase one row (32 instructions) at a time and to program 32 instructions at one time. rtsp may be used to program multiple program memory panels, but the table pointer must be changed at each panel boundary. each panel of program memory contains write latches that hold 32 instructions of programming data. prior to the actual programming operation, the write data must be loaded into the panel write latches. the data to be programmed into the panel is loaded in sequential order into the write latches; instruction ? 0 ?, instruction ? 1 ?, etc. the instruction words loaded must always be from a group of 32 boundary. the basic sequence for rtsp programming is to set up a table pointer, then do a series of tblwt instructions to load the write latches. programming is performed by setting the special bits in the nvmcon register. 32 tblwtl and four tblwth instructions are required to load the 32 instructions. if multiple panel programming is required, the table pointer needs to be changed and the next set of multiple write latches written. all of the table write operations are single-word writes (2 instruction cycles), because only the table latches are written. a programming cycle is required for programming each row. the flash program memory is readable, writable and erasable during normal operation over the entire v dd range. 7.5 control registers the four sfrs used to read and write the program flash memory are: ?nvmcon ? nvmadr ? nvmadru ? nvmkey 7.5.1 nvmcon register the nvmcon register controls which blocks are to be erased, which memory type is to be programmed and the start of the programming cycle. 7.5.2 nvmadr register the nvmadr register is used to hold the lower two bytes of the effective address. the nvmadr register captures the ea<15:0> of the last table instruction that has been executed and selects the row to write. 7.5.3 nvmadru register the nvmadru register is used to hold the upper byte of the effective address. the nvmadru register cap- tures the ea<23:16> of the last table instruction that has been executed. 7.5.4 nvmkey register nvmkey is a write-only register that is used for write protection. to start a programming or an erase sequence, the user must consecutively write 0x55 and 0xaa to the nvmkey register. refer to section 7.6 ?programming operations? for further details. note: the user can also directly write to the nvmadr and nvmadru registers to specify a program memory address for erasing or programming.
? 2006 microchip technology inc. advance information ds70178a-page 83 dspic30f1010/202x 7.6 programming operations a complete programming sequence is necessary for programming or erasing the internal flash in rtsp mode. a programming operation is nominally 2 msec in duration and the processor stalls (waits) until the oper- ation is finished. setting the wr bit (nvmcon<15>) starts the operation, and the wr bit is automatically cleared when the operation is finished. 7.6.1 programming algorithm for program flash the user can erase and program one row of program flash memory at a time. the general process is: 1. read one row of program flash (32 instruction words) and store into data ram as a data ?image?. 2. update the data image with the desired new data. 3. erase program flash row. a) setup nvmcon register for multi-word, program flash, erase and set wren bit. b) write address of row to be erased into nvmadru/nvmdr. c) write ?55? to nvmkey. d) write ?aa? to nvmkey. e) set the wr bit. this will begin erase cycle. f) cpu will stall for the duration of the erase cycle. g) the wr bit is cleared when erase cycle ends. 4. write 32 instruction words of data from data ram ?image? into the program flash write latches. 5. program 32 instruction words into program flash. a) setup nvmcon register for multi-word, program flash, program and set wren bit. b) write ?55? to nvmkey. c) write ?aa? to nvmkey. d) set the wr bit. this will begin program cycle. e) cpu will stall for duration of the program cycle. f) the wr bit is cleared by the hardware when program cycle ends. 6. repeat steps 1 through 5 as needed to program desired amount of program flash memory. 7.6.2 erasing a row of program memory example 7-1 shows a code sequence that can be used to erase a row (32 instructions) of program memory. example 7-1: erasing a row of program memory ; setup nvmcon for erase operation, multi word write ; program memory selected, and writes enabled mov #0x4041,w0 ; mov w0 , nvmcon ; init nvmcon sfr ; init pointer to row to be erased mov #tblpage(prog_addr),w0 ; mov w0 , nvmadru ; initialize pm page boundary sfr mov #tbloffset(prog_addr),w0 ; intialize in-page ea<15:0> pointer mov w0, nvmadr ; intialize nvmadr sfr disi #5 ; block all interrupts with priority <7 ; for next 5 instructions mov #0x55,w0 mov w0 , nvmkey ; write the 0x55 key mov #0xaa,w1 ; mov w1 , nvmkey ; write the 0xaa key bset nvmcon,#wr ; start the erase sequence nop ; insert two nops after the erase nop ; command is asserted
dspic30f1010/202x ds70178a-page 84 advance information ? 2006 microchip technology inc. 7.6.3 loading write latches example 7-2 shows a sequence of instructions that can be used to load the 96 bytes of write latches. 32 tblwtl and 32 tblwth instructions are needed to load the write latches selected by the table pointer. example 7-2: loading write latches 7.6.4 initiating the programming sequence for protection, the write initiate sequence for nvmkey must be used to allow any erase or program operation to proceed. after the programming command has been executed, the user must wait for the programming time until programming is complete. the two instructions following the start of the programming sequence should be nop s. example 7-3: initiating a programming sequence ; set up a pointer to the first program memory location to be written ; program memory selected, and writes enabled mov #0x0000,w0 ; mov w0 , tblpag ; initialize pm page boundary sfr mov #0x6000,w0 ; an example program memory address ; perform the tblwt instructions to write the latches ; 0th_program_word mov #low_word_0,w2 ; mov #high_byte_0,w3 ; tblwtl w2 , [w0] ; write pm low word into program latch tblwth w3 , [w0++] ; write pm high byte into program latch ; 1st_program_word mov #low_word_1,w2 ; mov #high_byte_1,w3 ; tblwtl w2 , [w0] ; write pm low word into program latch tblwth w3 , [w0++] ; write pm high byte into program latch ; 2nd_program_word mov #low_word_2,w2 ; mov #high_byte_2,w3 ; tblwtl w2 , [w0] ; write pm low word into program latch tblwth w3 , [w0++] ; write pm high byte into program latch ? ? ? ; 31st_program_word mov #low_word_31,w2 ; mov #high_byte_31,w3 ; tblwtl w2 , [w0] ; write pm low word into program latch tblwth w3 , [w0++] ; write pm high byte into program latch note: in example 7-2, the contents of the upper byte of w3 have no effect. disi #5 ; block all interrupts with priority <7 ; for next 5 instructions mov #0x55,w0 mov w0 , nvmkey ; write the 0x55 key mov #0xaa,w1 ; mov w1 , nvmkey ; write the 0xaa key bset nvmcon,#wr ; start the erase sequence nop ; insert two nops after the erase nop ; command is asserted
? 2006 microchip technology inc. advance information ds70178a-page 85 dspic30f1010/202x table 7-1: nvm register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets nvmcon 0760 wr wren wrerr ? ? ? ?twri ? progop<6:0> 0000 0000 0000 0000 nvmadr 0762 nvmadr<15:0> uuuu uuuu uuuu uuuu nvmadru 0764 ? ? ? ? ? ? ? ? nvmadr<23:16> 0000 0000 uuuu uuuu nvmkey 0766 ? ? ? ? ? ? ? ? key<7:0> 0000 0000 0000 0000 legend: u = uninitialized bit note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields.
dspic30f1010/202x ds70178a-page 86 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 87 dspic30f1010/202x 8.0 timer1 module this section describes the 16-bit general purpose (gp) timer1 module and associated operational modes. figure 8-1 depicts the simplified block diagram of the 16-bit timer1 module. the following sections provide a detailed description of the operational modes of the timers, including setup and control registers along with associated block diagrams. the timer1 module is a 16-bit timer which can serve as the time counter for the real-time clock, or operate as a free running interval timer/counter. the 16-bit timer has the following modes: ? 16-bit timer ? 16-bit synchronous counter ? 16-bit asynchronous counter further, the following operational characteristics are supported: ? timer gate operation ? selectable prescaler settings ? timer operation during cpu idle and sleep modes ? interrupt on 16-bit period register match or falling edge of external gate signal these operating modes are determined by setting the appropriate bit(s) in the 16-bit sfr, t1con. figure 8-1 presents a block diagram of the 16-bit timer module. 16-bit timer mode: in the 16-bit timer mode, the timer increments on every instruction cycle up to a match value, preloaded into the period register pr1, then resets to 0 and continues to count. when the cpu goes into the idle mode, the timer will stop incrementing, unless the tsidl (t1con<13>) bit = 0 . if tsidl = 1 , the timer module logic will resume the incrementing sequence upon termination of the cpu idle mode. 16-bit synchronous counter mode: in the 16-bit synchronous counter mode, the timer increments on the rising edge of the applied external clock signal, which is synchronized with the internal phase clocks. the timer counts up to a match value preloaded in pr1, then resets to 0 and continues. when the cpu goes into the idle mode, the timer will stop incrementing, unless the respective tsidl bit = 0 . if tsidl = 1 , the timer module logic will resume the incrementing sequence upon termination of the cpu idle mode. 16-bit asynchronous counter mode: in the 16-bit asynchronous counter mode, the timer increments on every rising edge of the applied external clock signal. the timer counts up to a match value preloaded in pr1, then resets to ? 0 ? and continues. when the timer is configured for the asynchronous mode of operation and the cpu goes into the idle mode, the timer will stop incrementing if tsidl = 1 . note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). note: timer1 is a ?type a? timer. please refer to the specifications for a type a timer in section 21.0 ?electrical characteris- tics? of this document.
dspic30f1010/202x ds70178a-page 88 advance information ? 2006 microchip technology inc. figure 8-1: 16-bit timer1 module block diagram (type a timer) 8.1 timer gate operation the 16-bit timer can be placed in the gated time accu- mulation mode. this mode allows the internal t cy to increment the respective timer when the gate input sig- nal (t1ck pin) is asserted high. control bit tgate (t1con<6>) must be set to enable this mode. the timer must be enabled (ton = 1 ) and the timer clock source set to internal (tcs = 0 ). when the cpu goes into the idle mode, the timer will stop incrementing, unless tsidl = 0 . if tsidl = 1 , the timer will resume the incrementing sequence upon termination of the cpu idle mode. 8.2 timer prescaler the input clock (f osc /2 or external clock) to the 16-bit timer, has a prescale option of 1:1, 1:8, 1:64, and 1:256 selected by control bits tckps<1:0> (t1con<5:4>). the prescaler counter is cleared when any of the following occurs: ? a write to the tmr1 register ? clearing of the ton bit (t1con<15>) ? device reset such as por however, if the timer is disabled (ton = 0 ), then the timer prescaler cannot be reset since the prescaler clock is halted. tmr1 is not cleared when t1con is written. it is cleared by writing to the tmr1 register. 8.3 timer operation during sleep mode during cpu sleep mode, the timer will operate if: ? the timer module is enabled (ton = 1 ) and ? the timer clock source is selected as external (tcs = 1 ) and ? the tsync bit (t1con<2>) is asserted to a logic ? 0 ?, which defines the external clock source as asynchronous when all three conditions are true, the timer will continue to count up to the period register and be reset to 0x0000. when a match between the timer and the period regis- ter occurs, an interrupt can be generated, if the respective timer interrupt enable bit is asserted. ton sync pr1 t1if equal comparator x 16 tmr1 reset event flag 1 0 tsync q qd ck tgate tckps<1:0> prescaler 1, 8, 64, 256 2 tgate t cy 1 0 t1ck tcs 1 x 0 1 tgate 0 0 (3) gate sync
? 2006 microchip technology inc. advance information ds70178a-page 89 dspic30f1010/202x 8.4 timer interrupt the 16-bit timer has the ability to generate an interrupt on period match. when the timer count matches the period register, the t1if bit is asserted and an interrupt will be generated, if enabled. the t1if bit must be cleared in software. the timer interrupt flag t1if is located in the ifs0 control register in the interrupt controller. when the gated time accumulation mode is enabled, an interrupt will also be generated on the falling edge of the gate signal (at the end of the accumulation cycle). enabling an interrupt is accomplished via the respec- tive timer interrupt enable bit, t1ie. the timer interrupt enable bit is located in the iec0 control register in the interrupt controller.
dspic30f1010/202x ds70178a-page 90 advance information ? 2006 microchip technology inc. table 8-1: timer1 register map sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state tmr1 0100 timer 1 register uuuu uuuu uuuu uuuu pr1 0102 period register 1 1111 1111 1111 1111 t1con 0104 ton ?tsidl ? ? ? ? ? ? tgate tckps1 tckps0 ?tsynctcs ? 0000 0000 0000 0000 legend: u = uninitialized bit note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields.
? 2006 microchip technology inc. advance information ds70178a-page 91 dspic30f1010/202x 9.0 timer2/3 module this section describes the 32-bit general purpose (gp) timer module (timer2/3) and associated opera- tional modes. figure 9-1 depicts the simplified block diagram of the 32-bit timer2/3 module. figure 9-2 and figure 9-3 show timer2/3 configured as two independent 16-bit timers: timer2 and timer3, respectively. the timer2/3 module is a 32-bit timer, which can be configured as two 16-bit timers, with selectable operat- ing modes. these timers are utilized by other peripheral modules such as: ? input capture ? output compare/simple pwm the following sections provide a detailed description, including setup and control registers, along with asso- ciated block diagrams for the operational modes of the timers. the 32-bit timer has the following modes: ? two independent 16-bit timers (timer2 and timer3) with all 16-bit operating modes (except asynchronous counter mode) ? single 32-bit timer operation ? single 32-bit synchronous counter further, the following operational characteristics are supported: ? adc event trigger ? timer gate operation ? selectable prescaler settings ? timer operation during idle and sleep modes ? interrupt on a 32-bit period register match these operating modes are determined by setting the appropriate bit(s) in the 16-bit t2con and t3con sfrs. for 32-bit timer/counter operation, timer2 is the least significant word and timer3 is the most significant word of the 32-bit timer. 16-bit mode: in the 16-bit mode, timer2 and timer3 can be configured as two independent 16-bit timers. each timer can be set up in either 16-bit timer mode or 16-bit synchronous counter mode. see section 8.0 ?timer1 module? for details on these two operating modes. the only functional difference between timer2 and timer3 is that timer2 provides synchronization of the clock prescaler output. this is useful for high-frequency external clock inputs. 32-bit timer mode: in the 32-bit timer mode, the timer increments on every instruction cycle up to a match value, preloaded into the combined 32-bit period regis- ter pr3/pr2, then resets to ? 0 ? and continues to count. for synchronous 32-bit reads of the timer2/timer3 pair, reading the least significant word (tmr2 register) will cause the most significant word to be read and latched into a 16-bit holding register, termed tmr3hld. for synchronous 32-bit writes, the holding register (tmr3hld) must first be written to. when followed by a write to the tmr2 register, the contents of tmr3hld will be transferred and latched into the msb of the 32-bit timer (tmr3). 32-bit synchronous counter mode: in the 32-bit synchronous counter mode, the timer increments on the rising edge of the applied external clock signal, which is synchronized with the internal phase clocks. the timer counts up to a match value preloaded in the combined 32-bit period register, pr3/pr2, then resets to ? 0 ? and continues. when the timer is configured for the synchronous counter mode of operation and the cpu goes into the idle mode, the timer will stop incrementing, unless the tsidl (t2con<13>) bit = 0 . if tsidl = 1 , the timer module logic will resume the incrementing sequence upon termination of the cpu idle mode. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). note: the dspic30f1010 device does not fea- ture timer3. timer2 is a ?type b? timer and timer3 is a ?type c? timer. please refer to the appropriate timer type in section 21.0 ?electrical characteristics? of this document. note: for 32-bit timer operation, t3con control bits are ignored. only t2con control bits are used for setup and control. timer 2 clock and gate inputs are utilized for the 32-bit timer module, but an interrupt is generated with the timer3 interrupt flag (t3if) and the interrupt is enabled with the timer3 interrupt enable bit (t3ie).
dspic30f1010/202x ds70178a-page 92 advance information ? 2006 microchip technology inc. figure 9-1: 32-bit timer2/3 block diagram tmr3 tmr2 t3if equal comparator x 32 pr3 pr2 reset lsb msb event flag note: timer configuration bit t32, (t2con<3>) must be set to ?1? for a 32-bit timer/counter operation. all control bits are respective to the t2con register. data bus<15:0> tmr3hld read tmr2 write tmr2 16 16 16 q qd ck tgate(t2con<6>) (t2con<6>) tgate 0 1 ton tckps<1:0> prescaler 1, 8, 64, 256 2 t cy tcs 1 x 0 1 tgate 0 0 gate t2ck sync adc event trigger sync
? 2006 microchip technology inc. advance information ds70178a-page 93 dspic30f1010/202x figure 9-2: 16-bit timer2 block diagram figure 9-3: 16-bit timer3 block diagram ton sync pr2 t2if equal comparator x 16 tmr2 reset event flag q qd ck tgate tckps<1:0> prescaler 1, 8, 64, 256 2 tgate t cy 1 0 tcs 1 x 0 1 tgate 0 0 gate t2ck sync ton pr3 t3if equal comparator x 16 tmr3 reset event flag q qd ck tgate tckps<1:0> prescaler 1, 8, 64, 256 2 tgate t cy 1 0 tcs 1 x 0 1 tgate 0 0 adc event trigger sync see note note: the dspic30f202x does not have an external pin input to timer3. the following modes should not be used: 1. tcs = 1 2. tcs = 0 and tgate = 1 (gated time accumulation)
dspic30f1010/202x ds70178a-page 94 advance information ? 2006 microchip technology inc. 9.1 timer gate operation the 32-bit timer can be placed in the gated time accu- mulation mode. this mode allows the internal t cy to increment the respective timer when the gate input sig- nal (t2ck pin) is asserted high. control bit tgate (t2con<6>) must be set to enable this mode. when in this mode, timer2 is the originating clock source. the tgate setting is ignored for timer3. the timer must be enabled (ton = 1 ) and the timer clock source set to internal (tcs = 0 ). the falling edge of the external signal terminates the count operation, but does not reset the timer. the user must reset the timer in order to start counting from zero. 9.2 adc event trigger when a match occurs between the 32-bit timer (tmr3/ tmr2) and the 32-bit combined period register (pr3/ pr2), a special adc trigger event signal is generated by timer3. 9.3 timer prescaler the input clock (f osc /2 or external clock) to the timer has a prescale option of 1:1, 1:8, 1:64, and 1:256 selected by control bits tckps<1:0> (t2con<5:4> and t3con<5:4>). for the 32-bit timer operation, the originating clock source is timer2. the prescaler oper- ation for timer3 is not applicable in this mode. the prescaler counter is cleared when any of the following occurs: ? a write to the tmr2/tmr3 register ? clearing either of the ton (t2con<15> or t3con<15>) bits to ? 0 ? ? device reset such as por however, if the timer is disabled (ton = 0 ), then the timer 2 prescaler cannot be reset, since the prescaler clock is halted. tmr2/tmr3 is not cleared when t2con/t3con is written. 9.4 timer operation during sleep mode during cpu sleep mode, the timer will not operate, because the internal clocks are disabled. 9.5 timer interrupt the 32-bit timer module can generate an interrupt on period match, or on the falling edge of the external gate signal. when the 32-bit timer count matches the respective 32-bit period register, or the falling edge of the external ?gate? signal is detected, the t3if bit (ifs0<7>) is asserted and an interrupt will be gener- ated if enabled. in this mode, the t3if interrupt flag is used as the source of the interrupt. the t3if bit must be cleared in software. enabling an interrupt is accomplished via the respective timer interrupt enable bit, t3ie (iec0<7>).
? 2006 microchip technology inc. advance information ds70178a-page 95 dspic30f1010/202x table 9-1: timer2/3 register map sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state tmr2 0106 timer2 register uuuu uuuu uuuu uuuu tmr3hld 0108 timer3 holding register (for 32-bit timer operations only) uuuu uuuu uuuu uuuu tmr3 010a timer3 register uuuu uuuu uuuu uuuu pr2 010c period register 2 1111 1111 1111 1111 pr3 010e period register 3 1111 1111 1111 1111 t2con 0110 ton ?tsidl ? ? ? ? ? ? tgate tckps1 tckps0 t32 ?tcs ? 0000 0000 0000 0000 t3con 0112 ton ?tsidl ? ? ? ? ? ? tgate tckps1 tckps0 ? ?tcs ? 0000 0000 0000 0000 legend: u = uninitialized bit note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields.
dspic30f1010/202x ds70178a-page 96 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 97 dspic30f1010/202x 10.0 input capture module this section describes the input capture module and associated operational modes. the features provided by this module are useful in applications requiring fre- quency (period) and pulse measurement. figure 10-1 depicts a block diagram of the input capture module. input capture is useful for such modes as: ? frequency/period/pulse measurements ? additional sources of external interrupts the key operational features of the input capture module are: ? simple capture event mode ? timer2 and timer3 mode selection ? interrupt on input capture event these operating modes are determined by setting the appropriate bits in the icxcon register (where x = 1,2,...,n). the dspic dsc devices contain up to 8 capture channels, (i.e., the maximum value of n is 8). figure 10-1: input capture mode block diagram note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). note: the dspic30f1010 devices does not fea- ture a input capture module. the dspic30f202x devices have one capture input ? ic1. the naming of this capture channel is intentional and preserves soft- ware compatibility with other dspic dsc devices. icxbuf prescaler icx icm<2:0> mode select 3 note: where ?x? is shown, reference is made to the registers or bits associated to the respective input capture channels 1 through n. 10 set flag pin icxif ictmr t2_cnt t3_cnt edge detection logic clock synchronizer 1, 4, 16 from gp timer module 16 16 fifo r/w logic ici<1:0> icbne, icov icxcon interrupt logic set flag icxif data bus
dspic30f1010/202x ds70178a-page 98 advance information ? 2006 microchip technology inc. 10.1 simple capture event mode the simple capture events in the dspic30f product family are: ? capture every falling edge ? capture every rising edge ? capture every 4th rising edge ? capture every 16th rising edge ? capture every rising and falling edge these simple input capture modes are configured by setting the appropriate bits icm<2:0> (icxcon<2:0>). 10.1.1 capture prescaler there are four input capture prescaler settings, speci- fied by bits icm<2:0> (icxcon<2:0>). whenever the capture channel is turned off, the prescaler counter will be cleared. in addition, any reset will clear the prescaler counter. 10.1.2 capture buffer operation each capture channel has an associated fifo buffer, which is four 16-bit words deep. there are two status flags, which provide status on the fifo buffer: ? icbfne ? input capture buffer not empty ? icov ? input capture overflow the icbfne will be set on the first input capture event and remain set until all capture events have been read from the fifo. as each word is read from the fifo, the remaining words are advanced by one position within the buffer. in the event that the fifo is full with four capture events and a fifth capture event occurs prior to a read of the fifo, an overflow condition will occur and the icov bit will be set to a logic ? 1 ?. the fifth capture event is lost and is not stored in the fifo. no additional events will be captured until all four events have been read from the buffer. if a fifo read is performed after the last read and no new capture event has been received, the read will yield indeterminate results. 10.1.3 timer2 and timer3 selection mode the input capture module consists of up to 8 input cap- ture channels. each channel can select between one of two timers for the time base, timer2 or timer3. selection of the timer resource is accomplished through sfr bit ictmr (icxcon<7>). timer3 is the default timer resource available for the input capture module. 10.1.4 hall sensor mode when the input capture module is set for capture on every edge, rising and falling, icm<2:0> = 001 , the fol- lowing operations are performed by the input capture logic: ? the input capture interrupt flag is set on every edge, rising and falling. ? the interrupt on capture mode setting bits, ici<1:0>, are ignored, since every capture generates an interrupt. ? a capture overflow condition is not generated in this mode.
? 2006 microchip technology inc. advance information ds70178a-page 99 dspic30f1010/202x 10.2 input capture operation during sleep and idle modes an input capture event will generate a device wake-up or interrupt, if enabled, if the device is in cpu idle or sleep mode. independent of the timer being enabled, the input capture module will wake-up from the cpu sleep or idle mode when a capture event occurs, if icm<2:0> = 111 and the interrupt enable bit is asserted. the same wake-up can generate an interrupt, if the conditions for processing the interrupt have been satisfied. the wake-up feature is useful as a method of adding extra external pin interrupts. 10.2.1 input capture in cpu sleep mode cpu sleep mode allows input capture module opera- tion with reduced functionality. in the cpu sleep mode, the ici<1:0> bits are not applicable, and the input capture module can only function as an external interrupt source. the capture module must be configured for interrupt only on the rising edge (icm<2:0> = 111 ), in order for the input capture module to be used while the device is in sleep mode. the prescale settings of 4:1 or 16:1 are not applicable in this mode. 10.2.2 input capture in cpu idle mode cpu idle mode allows input capture module operation with full functionality. in the cpu idle mode, the inter- rupt mode selected by the ici<1:0> bits are applicable, as well as the 4:1 and 16:1 capture prescale settings, which are defined by control bits icm<2:0>. this mode requires the selected timer to be enabled. moreover, the icsidl bit must be asserted to a logic ? 0 ?. if the input capture module is defined as icm<2:0> = 111 in cpu idle mode, the input capture pin will serve only as an external interrupt pin. 10.3 input capture interrupts the input capture channels have the ability to generate an interrupt, based upon the selected number of cap- ture events. the selection number is set by control bits ici<1:0> (icxcon<6:5>). each channel provides an interrupt flag (icxif) bit. the respective capture channel interrupt flag is located in the corresponding ifsx status register. enabling an interrupt is accomplished via the respec- tive capture channel interrupt enable (icxie) bit. the capture interrupt enable bit is located in the corresponding iec control register.
dspic30f1010/202x ds70178a-page 100 advance information ? 2006 microchip technology inc. table 10-1: input capture register map sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state ic1buf 0140 input 1 capture register uuuu uuuu uuuu uuuu ic1con 0142 ? ?icsidl ? ? ? ? ? ictmr ici<1:0> icov icbne icm<2:0> 0000 0000 0000 0000 legend: u = uninitialized bit note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields.
? 2006 microchip technology inc. advance information ds70178a-page 101 dspic30f1010/202x 11.0 output compare module this section describes the output compare module and associated operational modes. the features pro- vided by this module are useful in applications requiring operational modes such as: ? generation of variable width output pulses ? power factor correction figure 11-1 depicts a block diagram of the output compare module. the key operational features of the output compare module include: ? timer2 and timer3 selection mode ? simple output compare match mode ? dual output compare match mode ? simple pwm mode ? output compare during sleep and idle modes ? interrupt on output compare/pwm event these operating modes are determined by setting the appropriate bits in the 16-bit ocxcon sfr (where x = 1 and 2). ocxrs and ocxr in the figure represent the dual compare registers. in the dual compare mode, the ocxr register is used for the first compare and ocxrs is used for the second compare. figure 11-1: output compare mode block diagram note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). ocxr comparator output logic q s r ocm<2:0> output enable ocx set flag bit ocxif ocxrs mode select 3 note: where ?x? is shown, reference is made to the registers associated with the respective output compare channels 1 and 2. octsel 0 1 t2p2_match tmr2<15:0 tmr3<15:0> t3p3_match from gp timer module 0 1 ocflta
dspic30f1010/202x ds70178a-page 102 advance information ? 2006 microchip technology inc. 11.1 timer2 and timer3 selection mode each output compare channel can select between one of two 16-bit timers: timer2 or timer3. the selection of the timers is controlled by the octsel bit (ocxcon<3>). timer2 is the default timer resource for the output compare module. 11.2 simple output compare match mode when control bits ocm<2:0> (ocxcon<2:0>) = 001 , 010 or 011 , the selected output compare channel is configured for one of three simple output compare match modes: ? compare forces i/o pin low ? compare forces i/o pin high ? compare toggles i/o pin the ocxr register is used in these modes. the ocxr register is loaded with a value and is compared to the selected incrementing timer count. when a compare occurs, one of these compare match modes occurs. if the counter resets to zero before reaching the value in ocxr, the state of the ocx pin remains unchanged. 11.3 dual output compare match mode when control bits ocm<2:0> (ocxcon<2:0>) = 100 or 101 , the selected output compare channel is config- ured for one of two dual output compare modes, which are: ? single output pulse mode ? continuous output pulse mode 11.3.1 single pulse mode for the user to configure the module for the generation of a single output pulse, the following steps are required (assuming the timer is off): ? determine instruction cycle time t cy . ? calculate desired pulse width value based on t cy . ? calculate time to start pulse from timer start value of 0x0000. ? write pulse width start and stop times into ocxr and ocxrs compare registers (x denotes channel 1, 2). ? set timer period register to value equal to, or greater than, value in ocxrs compare register. ? set ocm<2:0> = 100 . ? enable timer, ton (txcon<15>) = 1 . to initiate another single pulse, issue another write to set ocm<2:0> = 100 . 11.3.2 continuous pulse mode for the user to configure the module for the generation of a continuous stream of output pulses, the following steps are required: ? determine instruction cycle time t cy . ? calculate desired pulse value based on t cy . ? calculate timer to start pulse width from timer start value of 0x0000. ? write pulse width start and stop times into ocxr and ocxrs (x denotes channel 1, 2) compare registers, respectively. ? set timer period register to value equal to, or greater than, value in ocxrs compare register. ? set ocm<2:0> = 101 . ? enable timer, ton (txcon<15>) = 1 . 11.4 simple pwm mode when control bits ocm<2:0> (ocxcon<2:0>) = 110 or 111 , the selected output compare channel is config- ured for the pwm mode of operation. when configured for the pwm mode of operation, ocxr is the main latch (read-only) and ocxrs is the secondary latch. this enables glitchless pwm transitions. the user must perform the following steps in order to configure the output compare module for pwm operation: 1. set the pwm period by writing to the appropriate period register. 2. set the pwm duty cycle by writing to the ocxrs register. 3. configure the output compare module for pwm operation. 4. set the tmrx prescale value and enable the timer, ton (txcon<15>) = 1 .
? 2006 microchip technology inc. advance information ds70178a-page 103 dspic30f1010/202x 11.4.1 pwm period the pwm period is specified by writing to the prx reg- ister. the pwm period can be calculated using equation 11-1. equation 11-1: pwm period pwm frequency is defined as 1 / [pwm period]. when the selected tmrx is equal to its respective period register, prx, the following four events occur on the next increment cycle: ? tmrx is cleared. ? the ocx pin is set. - exception 1: if pwm duty cycle is 0x0000, the ocx pin will remain low. - exception 2: if duty cycle is greater than prx, the pin will remain high. ? the pwm duty cycle is latched from ocxrs into ocxr. ? the corresponding timer interrupt flag is set. see figure 11-1 for key pwm period comparisons. timer3 is referred to in the figure for clarity. 11.4.2 pwm with fault protection input pin when control bits ocm<2:0> (ocxcon<2:0>) = 111 , fault protection is enabled via the ocflta pin. if the a logic ? 0 ? is detected on the ocflta pin, the output pins are placed in a high-impedance state. the state remains until: ? the external fault condition has been removed and ? the pwm mode is reenabled by writing to the appropriate control bits as a result of the fault condition, the ocxif interrupt is asserted, and an interrupt will be generated, if enabled. upon detection of the fault condition, the ocfltx bit in the ocxcon register is asserted high. this bit is a read-only bit and will be cleared once the external fault condition has been removed, and the pwm mode is reenabled by writing the appropriate mode bits, ocm<2:0> in the ocxcon register. 11.5 output compare operation during cpu sleep mode when the cpu enters the sleep mode, all internal clocks are stopped. therefore, when the cpu enters the sleep state, the output compare channel will drive the pin to the active state that was observed prior to entering the cpu sleep state. for example, if the pin was high when the cpu entered the sleep state, the pin will remain high. like- wise, if the pin was low when the cpu entered the sleep state, the pin will remain low. in either case, the output compare module will resume operation when the device wakes up. 11.6 output compare operation during cpu idle mode when the cpu enters the idle mode, the output compare module can operate with full functionality. the output compare channel will operate during the cpu idle mode if the ocsidl bit (ocxcon<13>) is at logic ? 0 ? and the selected time base (timer2 or timer3) is enabled and the tsidl bit of the selected timer is set to logic ? 0 ?. pwm period = [(prx) + 1] ? 4 ? t osc ? (tmrx prescale value)
dspic30f1010/202x ds70178a-page 104 advance information ? 2006 microchip technology inc. figure 11-1: pwm output timing 11.7 output compare interrupts the output compare channels have the ability to gener- ate an interrupt on a compare match, for whichever match mode has been selected. for all modes except the pwm mode, when a compare event occurs, the respective interrupt flag (ocxif) is asserted and an interrupt will be generated, if enabled. the ocxif bit is located in the corresponding ifs status register, and must be cleared in software. the interrupt is enabled via the respective compare inter- rupt enable (ocxie) bit, located in the corresponding iec control register. for the pwm mode, when an event occurs, the respec- tive timer interrupt flag (t2if or t3if) is asserted and an interrupt will be generated, if enabled. the if bit is located in the ifs0 status register, and must be cleared in software. the interrupt is enabled via the respective timer interrupt enable bit (t2ie or t3ie), located in the iec0 control register. the output com- pare interrupt flag is never set during the pwm mode of operation. period duty cycle tmr3 = duty cycle (ocxr) tmr3 = duty cycle (ocxr) tmr3 = pr3 t3if = 1 (interrupt flag) ocxr = ocxrs tmr3 = pr3 (interrupt flag) ocxr = ocxrs t3if = 1
? 2006 microchip technology inc. advance information ds70178a-page 105 dspic30f1010/202x table 11-1: output compare register map sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state oc1rs 0180 output compare 1 master register 0000 0000 0000 0000 oc1r 0182 output compare 1 slave register 0000 0000 0000 0000 oc1con 0184 ? ?ocsidl ? ? ? ? ? ? ? ? ocflt1 octsel1 ocm<2:0> 0000 0000 0000 0000 oc2rs 0186 output compare 2 master register 0000 0000 0000 0000 oc2r 0188 output compare 2 slave register 0000 0000 0000 0000 oc2con 018a ? ?ocsidl ? ? ? ? ? ? ? ? ocflt2 octsel2 ocm<2:0> 0000 0000 0000 0000 note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields.
dspic30f1010/202x ds70178a-page 106 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 107 dspic30f1010/202x 12.0 power supply pwm the pwm module on the dspic30f1010/202x device supports a wide variety of pwm modes and output for- mats. this pwm module is ideal for power conversion applications such as: ? dc/dc converters ? ac/dc power supplies ? uninterruptable power supply (ups) 12.1 features overview the ps pwm module incorporates these features: ? four pwm generators with eight i/o ? four independent time bases ? duty cycle resolution of 1.1 nsec @ 30 mips ? dead-time resolution of 4.2 nsec @ 30 mips ? phase-shift resolution of 4.2 nsec @ 30 mips ? frequency resolution of 8.4 nsec @ 30 mips ? supported pwm modes: - standard edge-aligned pwm - complementary pwm - push-pull pwm - multi-phase pwm - variable phase pwm - fixed off-time pwm - current reset pwm - current-limit pwm - independent time base pwm ? on-the-fly changes to: - pwm frequency - pwm duty cycle - pwm phase shift ? output override control ? independent current-limit and fault inputs ? special event comparator for scheduling other peripheral events ? each pwm generator has comparator for triggering adc conversions. figure 12-1 conceptualizes the pwm module in a sim- plified block diagram. figure 12-2 illustrates how the module hardware is partitioned for each pwm output pair for the complementary pwm mode. each func- tional unit of the pwm module is discussed in subsequent sections. the pwm module contains four pwm generators. the module has eight pwm output pins: pwm1h, pwm1l, pwm2h, pwm2l, pwm3h, pwm3l, pwm4h and pwm4l. for complementary outputs, these eight i/o pins are grouped into h/l pairs. 12.2 description the ps pwm module is designed for applications that require (a) high resolution at high pwm frequencies, (b) the ability to drive standard push-pull or half bridge converters or (c) the ability to create multi-phase pwm outputs. two common, medium-power converter topologies are push-pull and half-bridge. these designs require the pwm output signal to be switched between alternate pins, as provided by the push-pull pwm mode. phase-shifted pwm describes the situation where each pwm generator provides outputs, but the phase relationship between the generator outputs is specifiable and changeable. multi-phase pwm is often used to improve dc-dc converter load transient response, and reduce the size of output filter capacitors and inductors. multiple dc/ dc converters are often operated in parallel but phase shifted in time. a single pwm output operating at 250 khz has a period of 4 sec. but an array of four pwm channels, staggered by 1 sec each, yields an effective switching frequency of 1 mhz. multi-phase pwm appli- cations typically use a fixed-phase relationship. variable phase pwm is useful in zero voltage transi- tion (zvt) power converters. here the pwm duty cycle is always 50%, and the power flow is controlled by varying the relative phase shift between the two pwm generators. note: the pll must be enabled for the ps pwm module to function. this is achieved by using the fnosc<1:0> bits in the foscsel configuration register.
dspic30f1010/202x ds70178a-page 108 advance information ? 2006 microchip technology inc. figure 12-1: simplified conceptual block diagram of power supply pwm mux latch comparator timer pdc2 phase mux latch comparator timer pdc3 phase mux latch comparator timer pdc4 phase mux latch comparator timer pdc1 pwmconx lebconx channel 1 dead-time generator ptcon sevtcmp comparator special event ioconx pwm enable and mode control channel 3 dead-time generator channel 4 dead-time generator altdtrx, dtrx dead-time control special event postscaler sflt x pwm3l pwm3h pwm2l pwm2h 16-bit data bus pwm1l pwm1h fltconx pin and mode control mdc adc trigger control master duty cycle reg fault mode and pin control pin override control special event ptper timer period pwm gen #1 pwm gen #2 pwm gen #4 ptmr master time base phase pwm gen #3 channel 2 dead-time generator pwm4l pwm4h pwm user, current limit and fault override and routing logic fault clmt override logic trigger comparison value iflt x fault control logic trgconx control for blanking external input signals
? 2006 microchip technology inc. advance information ds70178a-page 109 dspic30f1010/202x figure 12-2: partitioned output pair, complementary pwm mode 12.3 control registers the following registers control the operation of the power supply pwm module. ? ptcon: pwm time base control register ? ptper: primary time base register ? sevtcmp: pwm special event register ? mdc: pwm master duty cycle register(1) ? pwmconx: pwm control register ? pdcx: pwm generator duty cycle register(1) ? phasex: pwm phase-shift register ? dtrx: pwm dead-time register ? altdtrx: pwm alternate dead-time register ? trgconx: pwm trigger control register ? ioconx: pwm i/o control register ? fclconx: pwm fault current-limit control register ? trigx: pwm trigger compare value register ? lebconx: leading edge blanking control regis- ter pwm duty cycle register duty cycle comparator fault override values channel override values fault pin assignment logic fault pin pwm x h pwm x l tmr < pdc pwm override logic dead time logic fault active phase offset m u x m u x timer/counter
dspic30f1010/202x ds70178a-page 110 advance information ? 2006 microchip technology inc. register 12-1: ptcon: pwm time base control register r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 pten ? ptsidl sestat seien eipu syncpol syncoen bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 syncen syncsrc<2:0> sevtps<3:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 pten: pwm module enable bit 1 = pwm module is enabled 0 = pwm module is disabled bit 14 unimplemented: read as ? 0 ? bit 13 ptsidl: pwm time base stop in idle mode bit 1 = pwm time base halts in cpu idle mode 0 = pwm time base runs in cpu idle mode bit 12 sestat: special event interrupt status bit 1 = special event interrupt is pending 0 = special event interrupt is not pending bit 11 seien: special event interrupt enable bit 1 = special event interrupt is enabled 0 = special event interrupt is disabled bit 10 eipu: enable immediate period updates bit 1 = active period register is updated immediately 0 = active period register updates occur on pwm cycle boundaries bit 9 syncpol: synchronize input polarity bit 1 = syncin polarity is inverted (low active) 0 = syncin is high active bit 8 syncoen: primary time base sync enable bit 1 = synco output is enabled 0 = synco output is disabled bit 7 syncen: external time base synchronization enable bit 1 = external synchronization of primary time base is enabled 0 = external synchronization of primary time base is disabled bit 6-4 syncsrc<2:0>: sync source selection bits 000 = synci 001 = reserved . . 111 = reserved bit 3-0 sevtps<3:0>: pwm special event trigger output postscale select bits 0000 = 1:1 postscale 0001 = 1:2 postscale | | | | 1111 = 1:16 postscale
? 2006 microchip technology inc. advance information ds70178a-page 111 dspic30f1010/202x register 12-2: ptper: primary time base register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ptper <15:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 ptper <7:3> ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-3 primary time base (ptmr) period value bits bit 2-0 unimplemented: read as ? 0 ?
dspic30f1010/202x ds70178a-page 112 advance information ? 2006 microchip technology inc. register 12-3: sevtcmp: pwm special event register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 sevtcmp <15:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 sevtcmp <7:3> ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-3 special event compare count value bits bit 2-0 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 113 dspic30f1010/202x register 12-4: mdc: pwm master duty cycle register (1) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 mdc<15:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 mdc<7:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-0 master pwm duty cycle value bits note 1: the minimum value for this register is 0x0008 and the maximum value is 0xffef.
dspic30f1010/202x ds70178a-page 114 advance information ? 2006 microchip technology inc. register 12-5: pwmconx: pwm control register hs/hc-0 hs/hc-0 hs/hc-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 fltstat clstat trgstat fltien clien trgien itb mdcs bit 15 bit 8 r/w-0 r/w-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 dtc<1:0> ? ? ? ? xpres iue bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 fltstat: fault interrupt status 1 = fault interrupt is pending 0 = no fault interrupt is pending this bit is cleared by setting fltien = 0 . note: software must clear the interrupt status here, and the corresponding ifs bit in interrupt controller. bit 14 clstat: current-limit interrupt status bit 1 = current-limit interrupt is pending 0 = no current-limit interrupt is pending this bit is cleared by setting clien = 0 . note: software must clear the interrupt status here, and the corresponding ifs bit in interrupt controller. bit 13 trigien: trigger interrupt status bit 1 = trigger interrupt is pending 0 = no trigger interrupt is pending this bit is cleared by setting trgien = 0 . bit 12 fltien: fault interrupt enable bit 1 = fault interrupt enabled 0 = fault interrupt disabled and fltstat bit is cleared bit 11 clien: current-limit interrupt enable bit 1 = current-limit interrupt enabled 0 = current-limit interrupt disabled and clstat bit is cleared bit 10 trigien: trigger interrupt enable bit 1 = a trigger event generates an interrupt request 0 = trigger event interrupts are disabled and trgstat bit is cleared bit 9 itb: independent time base mode bit 0 = primary time base provides timing for this pwm generator 1 = phasex register provides time base period for this pwm generator bit 8 mdcs: master duty cycle register select bit 0 = dcx register provides duty cycle information for this pwm generator 1 = mdc register provides duty cycle information for this pwm generator bit 7-6 dtc<1:0>: dead-time control bits 00 = positive dead time actively applied for all output modes 01 = negative dead time actively applied for all output modes 10 = dead-time function is disabled 11 = reserved bit 5-2 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 115 dspic30f1010/202x bit 1 xpres: external pwm reset control bit 1 = current-limit source resets time base for this pwm generator if it is in independent time base mode 0 = external pins do not affect pwm time base bit 0 iue: immediate update enable bit 1 = updates to the active pdc registers are immediate 0 = updates to the active pdc registers are synchronized to the pwm time base register 12-6: pdcx: pwm generator duty cycle register (1) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 pdcx<15:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 pdcx<7:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-0 pwm generator #x duty cycle value bits note 1: the minimum value for this register is 0x0008 and the maximum value is 0xffef. register 12-5: pwmconx: pwm control register (continued)
dspic30f1010/202x ds70178a-page 116 advance information ? 2006 microchip technology inc. register 12-7: phasex: pwm phase-shift register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 phasex<15:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 phasex<7:2> ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-2 phasex<15:2>: pwm phase-shift value or independent time base period for this pwm generator bits note: if used as an independent time base, bits <3:2> are not used. bit 1-0 unimplemented: read as ? 0 ? register 12-8: dtrx: pwm dead-time register u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ?dtrx<13:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 dtrx<7:2> ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-14 unimplemented: read as ? 0 ? bit 13-2 dtrx<13:2>: unsigned 11-bit dead-time value bits for pwmx dead-time unit bit 1-0 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 117 dspic30f1010/202x register 12-9: altdtrx: pwm alternate dead-time register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? altdtrx<13:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 altdtr <7:2> ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-14 unimplemented: read as ? 0 ? bit 13-2 altdtrx<13:2>: unsigned 11-bit dead-time value bits for pwmx dead-time unit bit 1-0 unimplemented: read as ? 0 ?
dspic30f1010/202x ds70178a-page 118 advance information ? 2006 microchip technology inc. register 12-10: trgconx: pw m trigger control register r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 u-0 trgdiv<2:0> ? ? ? ? ? bit 15 bit 8 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ?trgstrt<5:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-13 trgdiv<2:0>: trigger output divider 000 = trigger output for every trigger event 001 = trigger output for every 2nd trigger event 010 = trigger output for every 3rd trigger event 011 = trigger output for every 4th trigger event 100 = trigger output for every 5th trigger event 101 = trigger output for every 6th trigger event 110 = trigger output for every 7th trigger event 111 = trigger output for every 8th trigger event bit 12-6 unimplemented: read as ? 0 ? bit 5-0 trgstrt<5:0>: trigger postscaler start enable select bits this value specifies the roll counter value needed for a match that will then enable the trigger postscaler logic to begin counting trigger events.
? 2006 microchip technology inc. advance information ds70178a-page 119 dspic30f1010/202x register 12-11: ioconx: pwm i/o control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 penh penl polh poll pmod<1:0> ovrenh ovrenl bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 ovrdat<1:0> fltdat<1:0> cldat<1:0> ? osync bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 penh: pwmh output pin ownership bit 1 = pwm module controls pwmxh pin 0 = gpio module controls pwmxh pin bit 14 penl: pwml output pin ownership bit 1 = pwm module controls pwmxl pin 0 = gpio module controls pwmxl pin bit 13 polh: pwmh output pin polarity bit 0 = pwmxh pin is high active 1 = pwmxh pin is low active bit 12 poll: pwml output pin polarity bit 0 = pwmxl pin is high active 1 = pwmxl pin is low active bit 11-10 pmod<1:0>: pwm #x i/o pin mode bits 00 = pwm i/o pin pair is in the complementary output mode 01 = pwm i/o pin pair is in the independent output mode 10 = pwm i/o pin pair is in the push-pull output mode 11 = reserved bit 9 ovrenh: override enable for pwmxh pin bit 0 = pwm generator provides data for pwmxh pin 1 = ovrdat[1] provides data for output on pwmxh pin bit 8 ovrenl: override enable for pwmxl pin bit 0 = pwm generator provides data for pwmxl pin 1 = ovrdat[0] provides data for output on pwmxl pin bit 7-6 ovrdat<1:0>: data for pwmxh,l pins if override is enabled bits if overenh = 1 then ovrdat<1> provides data for pwmxh if overenl = 1 then ovrdat<0> provides data for pwmxl bit 5-4 fltdat<1:0>: data for pwmxh,l pins if fltmode is enabled bits if fault active, then fltdat<1> provides data for pwmxh if fault active, then fltdat<0> provides data for pwmxl bit 3-2 cldat<1:0>: data for pwmxh,l pins if clmode is enabled bits if current limit active, then cldat<1> provides data for pwmxh if current limit active, then cldat<0> provides data for pwmxl bit 1 unimplemented: read as ? 0 ? bit 0 osync: output override synchronization bit 1 = output overrides via the ovrdat<1:0> bits are synchronized to the pwm time base 0 = output overrides via the ovddat<1:0> bits occur on next clock boundary
dspic30f1010/202x ds70178a-page 120 advance information ? 2006 microchip technology inc. register 12-12: fclconx: pwm fau lt current-limit control register u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? ? clsrc<3:0> clpol bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 clmode fltsrc<3:0> fltpol fltmod<1:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-13 unimplemented: read as ? 0 ? bit 12-9 clsrc<3:0>: current-limit control signal source select for pwm #x generator bits 0000 = analog comparator #1 0001 = analog comparator #2 0010 = analog comparator #3 0011 = analog comparator #4 0100 = reserved 0101 = reserved 0110 = reserved 0111 = reserved 1000 = shared fault #1 (sflt1) 1001 = shared fault #2 (sflt2) 1020 = shared fault #3 (sflt3) 1011 = shared fault #4 (sflt4) 1100 = reserved 1101 = independent fault #2 (iflt2) 1110 = reserved 1111 = independent fault #4 (iflt4) bit 8 clpol: current-limit polarity for pwm generator #x bit 0 = the selected current-limit source is high active 1 = the selected current-limit source is low active bit 7 clmode: current-limit mode enable for pwm generator #x bit 1 = current-limit function is enabled 0 = current-limit function is disabled
? 2006 microchip technology inc. advance information ds70178a-page 121 dspic30f1010/202x bit 6-3 fltsrc<3:0>: fault control signal source select for pwm generator #x bits 0000 = analog comparator #1 0001 = analog comparator #2 0010 = analog comparator #3 0011 = analog comparator #4 0100 = reserved 0101 = reserved 0110 = reserved 0111 = reserved 1000 = shared fault #1 (sflt1) 1001 = shared fault #2 (sflt2) 1020 = shared fault #3 (sflt3) 1011 = shared fault #4 (sflt4) 1100 = reserved 1101 = independent fault #2 (iflt2) 1110 = reserved 1111 = independent fault #4 (iflt4) bit 2 fltpol: fault polarity for pwm generator #x bit 0 = the selected fault source is high active 1 = the selected fault source is low active bit 1-0 fltmod<1:0>: fault mode for pwm generator #x bits 00 = reserved 01 = the selected fault source forces pwmxh, pwmxl pins to fltdat values (cycle) 10 = reserved 11 = fault input is disabled register 12-12: fclconx: pwm fault current -limit control register (continued)
dspic30f1010/202x ds70178a-page 122 advance information ? 2006 microchip technology inc. register 12-13: trigx: pwm trigger compare value register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 trgcmp<15:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 trgcmp<7:3> ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-3 trgcmp<15:3>: trigger control value bits register contains the compare value for pwmx time base for generating a trigger to the adc module for initiating a sample and conversion process, or generating a trigger interrupt. bit 2-0 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 123 dspic30f1010/202x register 12-14: lebconx: leading edge blanking control register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 phr phf plr plf fltleben clleben leb<9:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 leb<7:3> ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 phr: pwmh rising edge trigger enable bit 1 = rising edge of pwmh will trigger leb counter 0 = leb ignores rising edge of pwmh bit 14 phl: pwmh falling edge trigger enable bit 1 = falling edge of pwmh will trigger leb counter 0 = leb ignores falling edge of pwmh bit 13 plr: pwml rising edge trigger enable bit 1 = rising edge of pwml will trigger leb counter 0 = leb ignores rising edge of pwml bit 12 plf: pwml falling edge trigger enable bit 1 = falling edge of pwml will trigger leb counter 0 = leb ignores falling edge of pwml bit 11 fltleben: fault input leading edge blanking enable bit 1 = leading edge blanking is applied to selected fault input 0 = leading edge blanking is not applied to selected fault input bit 10 clleben: current-limit leading edge blanking enable bit 1 = leading edge blanking is applied to selected current-limit input 0 = leading edge blanking is not applied to selected current-limit input bit 9-3 leb: leading edge blanking for current-limit and fault inputs bits value is 8 nsec increments bit 2-0 unimplemented: read as ? 0 ?
dspic30f1010/202x ds70178a-page 124 advance information ? 2006 microchip technology inc. 12.4 module functionality the ps pwm module is a very high-speed design that provides capabilities not found in other pwm genera- tors. the module supports these pwm modes: ? standard edge-aligned pwm mode ? complementary pwm mode ? push-pull pwm mode ? multi-phase pwm mode ? variable phase pwm mode ? current-limit pwm mode ? constant off-time pwm mode ? current reset pwm mode ? independent time base pwm mode 12.4.1 standard edge-aligned pwm mode standard edge-aligned mode (figure 12-3) is the basic pwm mode used by many power converter topologies such as ?buck?, ?boost? and ?forward?. to create the edge-aligned pwm, a timer/counter circuit counts upward from zero to a specified maximum value for the period. another register contains the value for duty cycle, which is constantly compared to the timer (period) value. while the timer/counter value is less than or equal to the duty cycle value, the pwm output signal is asserted. when the timer value exceeds the duty cycle value, the pwm signal is deasserted. when the timer is greater than the period value, the timer is reset, and the process repeats. figure 12-3: edge-aligned pwm 12.4.2 complementary pwm mode complementary pwm is generated in a manner similar to standard edge-aligned pwm. complementary mode provides a second pwm output signal on the pwml pin that is the complement of the primary pwm signal (pwmh). complementary mode pwm is shown in figure 12-4. figure 12-4: complementary pwm 12.4.3 push-pull pwm mode the push-pull mode shown in figure 12-5 is a version of the standard edge-aligned pwm mode where the active pwm signal is alternately outputted on one of two pwm pins. there is no complementary pwm out- put available. this mode is useful in transformer-based power converters. transformer-based circuits must avoid any direct currents that will cause their cores to saturate. the push-pull mode ensures that the duty cycle of the two phases is identical, thus yielding a net dc bias of zero. figure 12-5: push-pull pwm period duty cycle 0 period timer value timer resets pwmh value duty cycle match period duty cycle 0 period timer value timer resets pwmh value pwml (period)-(duty cycle) duty cycle match period duty cycle 0 period timer value timer resets pwmh value pwml duty cycle duty cycle match
? 2006 microchip technology inc. advance information ds70178a-page 125 dspic30f1010/202x 12.4.4 multi-phase pwm mode multi-phase pwm, as shown in figure 12-6, uses phase-shift values in the phase registers to shift the pwm outputs relative to the primary time base. because the phase-shift values are added to the pri- mary time base, the phase-shifted outputs occur earlier than a pwm channel that specifies zero phase shift. in multi-phase mode, the specified phase shift is fixed by the application?s design. figure 12-6: multi-phase pwm 12.4.5 variable phase pwm mode figure 12-7 shows the waveforms for variable phase- shift pwm. power-converter circuits constantly change the phase shift among pwm channels as a means to control the flow of power, in contrast to most pwm cir- cuits that vary the duty cycle of pwm signals to control power flow. often, in variable phase applications, the pwm duty cycle is maintained at 50%. the phase-shift value should be updated when the pwm signal is not asserted. complementary outputs are available in vari- able phase-shift mode. figure 12-7: variable phase pwm 12.4.6 current-limit pwm mode figure 12-8 shows cycle-by-cycle current-limit mode. this mode truncates the asserted pwm signal when the selected external fault signal is asserted. the pwm output values are specified by the fault override bits (fltdat<1:0>) in the ioconx register. the override output remains in effect until the begin- ning of the next pwm cycle. this mode is sometimes used in power factor correction (pfc) circuits where the inductor current controls the pwm on time. this is a constant frequency pwm mode. figure 12-8: cycle-by-cycle current-limit pwm mode 12.4.7 constant off-time pwm constant off-time mode is shown in figure 12-9. constant off-time pwm is a variable-frequency mode where the actual pwm period is less than or equal to the specified period value. the pwm time base is externally reset some time after the pwm signal duty cycle value has been reached, and the pwm signal has been deasserted. this mode is implemented by enabling the on-time pwm mode (current reset mode) and using the complementary output. duty cycle pwm2h duty cycle pwm4h duty cycle pwm3h duty cycle pwm1h period phase4 phase2 phase3 ptmr=0 duty cycle pwm1h period duty cycle duty cycle phase2 (old value) duty cycle pwm2h phase2 (new value) duty cycle 0 period timer value pwmh value fltx negates pwm duty cycle programmed duty cycle programmed duty cycle pwmh duty cycle actual actual fltx negates pwm
dspic30f1010/202x ds70178a-page 126 advance information ? 2006 microchip technology inc. figure 12-9: constant off-time pwm 12.4.8 current reset pwm mode current reset pwm is shown in figure 12-10. current reset pwm uses a variable-frequency mode where the actual pwm period is less than or equal to the spec- ified period value. the pwm time base is externally reset some time after the pwm signal duty cycle value has been reached and the pwm signal has been deas- serted. current reset pwm is a constant on-time pwm mode. figure 12-10: current reset pwm typically, in the converter application, an energy stor- age inductor is charged with current while the pwm signal is asserted, and the inductor current is dis- charged by the load when the pwm signal is deas- serted. in this application of current reset pwm, an external current measurement circuit determines when the inductor is discharged, and then generates a signal that the pwm module uses to reset the time base counter. in current reset mode, complementary outputs are available. 12.4.9 independent time base pwm independent time base pwm, as shown in figure 12-11, is often used when the dspic dsc is controlling different power converter subcircuits such as the power factor correction circuit, which may use 100 khz pwm, and the full-bridge forward converter section may use 250 khz pwm. figure 12-11: independent time base pwm duty cycle 0 period timer value programmed period pwml value external timer reset duty cycle actual period external timer reset note: duty cycle represents off time duty cycle 0 period timer value programmed period pwmh value external timer reset duty cycle actual period external timer rese t programmed period duty cycle pwm2h duty cycle pwm4h duty cycle pwm3h duty cycle pwm1h period 4 period 2 period 3 period 1 note: with independent time bases, pwm signals are no longer phase related to each other.
? 2006 microchip technology inc. advance information ds70178a-page 127 dspic30f1010/202x 12.5 primary pwm time base there is a primary time base (ptmr) counter for the entire pwm module, in addition, each pwm generator has an individual time base counter. the ptmr determines when the individual time base counters are to update their duty cycle and phase-shift registers. the master time base is also responsible for generating the special event triggers and timer-based interrupts. figure 12-12 shows a block diagram of the primary time base logic. figure 12-12: ptmr block diagram the primary time base may be reset by an external signal specified via the syncsrc<2:0> bits in the ptcon register. the external reset feature is enabled via the syncen bit in the ptcon register. the pri- mary time base reset feature supports synchronization of the primary time base with another smps dspic dsc device or other circuitry in the user?s application. the primary time base logic also provides an output signal when a period match occurs that can be used to synchronize an external device such as another smps dspic dsc. 12.5.1 ptmr synchronization because absolute synchronization is not possible, the user should program the time base period of the sec- ondary (slave) device to be slightly larger than the pri- mary device time base to ensure that the two time bases will reset at the same time. 12.6 primary pwm time base roll counter the primary time base has an additional 6-bit counter that counts the period matches of the primary time base. this roll counter enables the pwm genera- tors to stagger their trigger events in time to the adc module. this counter is not accessible for reading. each pwm generator has six bits (trgstrt<5:0>) in the trgconx registers. these bits are used to spec- ify the start enable for each trigx postscaler con- trolled by the trgdiv<2:0> bits in the trgconx registers. the tdiv bits specify how frequently a trigger pulse is generated, and the roll bits specify when the sequence begins. once the trig postscaler is enabled, the roll bits and the trgstrt bits have no further effect until the pwm module is disabled and then reenabled. the purpose of the roll counter and the trgstrt bits is to allow the user to spread the system work load over a series of pwm cycles. an additional use of the roll counter is to allow the internal frc oscillator to be varied on a pwm cycle basis to reduce peak emi emissions generated by switching transistors in the power conversion application. the roll counter is cleared when the pwm module is disabled (pten = 0 ), and the trigx postscalers are disabled, requiring a new roll versus trgstrt match to begin counting again. 12.7 individual pwm time base(s) each pwm generator also has its own pwm time base. figure 12-13 shows a block diagram for the indi- vidual time base circuits. with a time base per pwm generator, the pwm module can generate pwm out- puts that are phase shifted relative to each other, or totally independent of each other. the individual pwm timers (tmrx) provide the time base values that are compared to the duty cycle registers to create the pwm signals. the user may initialize these individual time base counters before or during operation via the phase-shift registers. the primary (ptmr) and the individual timers (tmrx) are not user readable. ptmr period equality comparator clk > reset 12 12 pr_match
dspic30f1010/202x ds70178a-page 128 advance information ? 2006 microchip technology inc. figure 12-13: tmrx block diagram normally, the primary time base (ptmr) provides synchronization control to the individual timer/counters so they count in lock-step unison. if the pwm phase-shift feature is used, then the ptmr provides the synchronization signal to each individual timer/counter that causes them to reinitialize with their individual phase-shift values. if a pwm generator is operating in independent time base mode, the individual timer/counters count upward until their count values match the value stored in their phase registers, then they reset and the cycle repeats. the primary time base and the individual time bases are implemented as 13-bit counters. the timers/ counters are clocked at 120 mhz @ 30 mips, which provides a frequency resolution of 8.4 nsec. all of the timer/counters are enabled/disabled by set- ting/clearing the pten bit in the ptcon sfr. the timers are cleared when the pten bit is cleared in software. the ptper register sets the counting period for ptmr. the user must write a 13-bit value to ptper<15:3>. when the value in ptmr<15:3> matches the value in ptper<15:3>, the primary time base is reset to ? 0 ?, and the individual time base counters are reinitialized to their phase values (except if in independent time base mode). 12.8 pwm period ptper holds the 13-bit value that specifies the count- ing period for the primary pwm time base. the timer period can be updated at any time by the user. the pwm period can be determined from the following formula: period duration = (ptper + 1) / 120 mhz @ 30 mips 12.9 pwm frequency and duty cycle resolution the pwm duty cycle resolution is 1.05 nsec per lsb @ 30 mips. the pwm period resolution is 8.4 nsec @ 30 mips. table 12-1 shows the duty cycle resolution versus pwm frequencies for 30 mips execution speed. table 12-1: available pwm frequencies and resolutions @ 30 mips table 12-2: available pwm frequencies and resolutions @ 20 mips notice the reduction in available resolution for a given pwm frequency is due to the reduced clock rate and the fact that the lsb of duty cycle resolution is derived from a fixed-delay element. at operating frequencies below 30 mips, the contribution of the fixed-delay ele- ment to the output resolution becomes less than 1 lsb. for frequency resonant mode power conversion appli- cations, it is desirable to know the available pwm fre- quency resolution. the available frequency resolution varies with the pwm frequency. the pwm time base clocks at 120 mhz @ 30 mips. the following equation provides the frequency resolution versus pwm period: frequency resolution = 120 mhz / (period) where period = ptper<15:3> tmrx ptper comparator clk > reset 12 12 mux phasex itbx 0 1 15 4 15 4 15 4 mips pwm duty cycle resolution pwm frequency 30 16 bits 14.6 khz 30 15 bits 29.3 khz 30 14 bits 58.6 khz 30 13 bits 117.2 khz 30 12 bits 234.4 khz 30 11 bits 468.9 khz 30 10 bits 937.9 khz 30 9 bits 1.87 mhz 30 8 bits 3.75 mhz mips pwm duty cycle resolution pwm frequency 20 14 bits 39 khz 20 12 bits 156 khz 20 10 bits 624 khz 20 8 bits 2.5 mhz
? 2006 microchip technology inc. advance information ds70178a-page 129 dspic30f1010/202x 12.10 pwm duty cycle comparison units the pwm module has two to four pwm duty cycle generators. three to five 16-bit special function regis- ters are used to specify duty cycle values for the pwm module: ? mdc (master duty cycle) ? pdc1, ..., pdc4 (duty cycle) each pwm generator has its own duty cycle register (dcx), and there is a master duty cycle (mdc) regis- ter. the mdc register can be used instead of individ- ual duty cycle registers. the mdc register enables multiple pwm generators to share a common duty cycle register to reduce the cpu overhead required in updating multiple duty cycle registers. multi-phase power converters are an application where the use of the mdc feature saves valuable processor time. the value in each duty cycle register determines the amount of time that the pwm output is in the active state. the pwm time base counters are 13 bits wide and increment twice per instruction cycle. the pwm output is asserted when the timer/counter is less than or equal to the most significant 13 bits of the duty cycle register value. each of the duty cycle registers allows a 16-bit duty cycle to be specified. the least significant 3 bits of the duty cycle registers are sent to additional logic for further adjustment of the pwm signal edge. figure 12-14 is a block diagram of a duty cycle comparison unit. figure 12-14: duty cycle comparison the duty cycle values can be updated at any time. the updated duty cycle values optionally can be held until the next rollover of the primary time base before becoming active. 12.11 complementary pwm outputs complementary pwm output mode provides true and inverted pwm outputs on the pair of pwm output pins. the complement pwm signal is generated by inverting the active pwm signal. complementary outputs are normally available with all of the different pwm modes except push-pull pwm and independent pwm output modes. 12.12 independent pwm outputs independent pwm output mode simply replicates the active pwm output signal on both output pins associated with a pwm generator. 12.13 duty cycle limits the duty cycle generators are limited to the range of allowable values. a value of 0x0008 is the minimum duty cycle value that will produce an output pulse. this value represents 8.4 nsec at 30 mips. this minimum range limitation is not a problem in a real world appli- cation because of the slew-rate limitation of the pwm output buffers, external fet drivers, and the power transistors. the application control loop requires larger duty cycle values to achieve minimum transistor on times. the maximum duty cycle value is also limited to 0xffef. the user is responsible for limiting the duty cycle values to the allowable range of 0x0008 to 0xffef. pdcx register tmrx compare logic pwmx signal 4 15 15 mux mdc register mdcx select 01 clk 15 4 4 <= note: a duty cycle of 0x0000 will produce a zero pwm output, and a 0xffff duty cycle value will produce a high on the pwm output.
dspic30f1010/202x ds70178a-page 130 advance information ? 2006 microchip technology inc. 12.14 dead-time generation dead time refers to a programmable period of time, specified by the dead-time register (dtr) or the alt- dtr register, which prevent a pwm output from being asserted until its complementary pwm signal has been deasserted for the specified time. figure 12-15 shows the insertion of dead time in a complementary pair of pwm outputs. figure 12-16 shows the four dead-time units that each have their own dead-time value. dead-time generation can be provided when any of the pwm i/o pin pairs are operating in any output mode. many power-converter circuits require dead time because the power transistors cannot switch instanta- neously. to prevent current ?shoot-through? some amount of time must be provided between the turn-off event of one pwm output in a complementary pair and the turn-on event of the other transistor. the pwm module can also provide negative dead time. negative dead time is the forced overlap of the pwmh and pwml signals. there are certain converter tech- niques that require a limited amount of current ?shoot-through?. the dead-time feature can be disabled for each pwm generator. the dead-time functionality is controlled by the dtcx<1:0> bits in the pwmcon register. figure 12-15: dead-time insertion for complementary pwm figure 12-16: de ad-time control units block diagram 12.14.1 dead-time generators each complementary output pair for the pwm module has 12-bit down counters to produce the dead-time insertion. each dead-time unit has a rising and falling edge detector connected to the duty cycle comparison output. depending on whether the edge is rising or falling, one of the transitions on the complementary outputs is delayed until the associated timer counts down to zero. a timing diagram indicating the dead-time inser- tion for one pair of pwm outputs is shown in figure 12-15. 12.14.2 alternate dead-time source the alternate dead time refers to the dead time speci- fied by the altdtr register that is applied to the com- plementary pwm output. figure 12-17 shows a dual dead-time insertion using the altdtr register. pwm1h pwm1l t da t da pwm generator #1 output dtr1 dead-time unit #1 pwm1 in pwm1h pwm1l altdr1 dtr2 dead-time unit #2 pwm2 in pwm2h pwm2l altdtr2 dtr3 dead-time unit #3 pwm3 in pwm3h pwm3l altdtr3 dtr4 dead-time unit #4 pwm4 in pwm4h pwm4l altdtr4
? 2006 microchip technology inc. advance information ds70178a-page 131 dspic30f1010/202x figure 12-17: dual dead-time waveforms 12.14.3 dead-time ranges the amount of dead time provided by each dead-time unit is selected by specifying a 12-bit unsigned value in the dtrx registers. the 12-bit dead-time counters clock at four times the instruction execution rate. the least significant one bit of the dead-time value are processed by the fine adjust pwm module. table 12-3 shows example dead-time ranges as a function of the device operating frequency. table 12-3: example dead-time ranges 12.14.4 dead-time insertion timing figure 12-18 shows how the dead-time insertion for complementary signals is accomplished. 12.14.5 dead-time distortion for small pwm duty cycles, the ratio of dead time to the active pwm time may become large. in this case, the inserted dead time introduces distortion into wave- forms produced by the pwm module. the user can ensure that dead-time distortion is minimized by keep- ing the pwm duty cycle at least three times larger than the dead time. a similar effect occurs for duty cycles at or near 100%. the maximum duty cycle used in the application should be chosen such that the minimum inactive time of the signal is at least three times larger than the dead time. figure 12-18: dead-time insertion (pwm output signal timing may be delayed) pwmh pwml pwml pwml pwmh pwmh no dead time positive dead time negative dead time dtrx altdtrx mips resolution dead-time range 30 4.16 ns 0-16.3 usec 20 6.25 ns 0-24.5 usec 90 123 4 5 6 78 clock ptmr duty cycle reg 4 raw pwmh raw pwml pwmh output pwml output dead-time value 1 <10:4> <15:4>
dspic30f1010/202x ds70178a-page 132 advance information ? 2006 microchip technology inc. 12.15 speed limits of pwm output circuitry the pwm output i/o buffers, and any attached circuits such as fet drivers and power fets, have limited slew-rate capability. for very small pwm duty cycles, the pwm output signal is low-pass filtered; no pulse makes it through all of the circuitry. a similar effect happens for duty cycle values near 100%. before 100% duty cycle is reached, the output pwm signal appears to saturate at 100%. users need to take such behavior into account in their applications. in normal power conversion applications, duty cycle values near 0% or 100% are avoided because to reach these values is to operate in a dis- continuous mode or a saturated mode where the control loop may be non functional. 12.16 pwm special event trigger the pwm module has a special event trigger that allows a/d conversions to be synchronized to the pwm time base. the a/d sampling and conversion time can be programmed to occur at any point within the pwm period. the special event trigger allows the user to minimize the delay between the time when a/d conver- sion results are acquired and the time when the duty cycle value is updated. the special event trigger is based on the primary pwm time base. the pwm special event trigger has one register (sevtcmp) and four additional control bits (sevops<3:0> in ptcon) to control its operation. the ptmr value that causes a special event trigger is loaded into the sevtcmp register. 12.16.1 special event trigger enable the pwm module always produces special event trig- ger pulses. this signal can optionally be used by the a/d module. 12.16.2 special event trigger postscaler the pwm special event trigger has a postscaler that allows a 1:1 to 1:16 postscale ratio. the postscaler is configured by writing the sevops3:sevops0 control bits in the ptcon register. the special event output postscaler is cleared on the following events: ? any write to the sevtcmp register. ? any device reset. 12.17 individual pwm triggers the pwm module also features an additional adc trig- ger output for each pwm generator. this feature is very useful when the pwm generators are operating in independent time base mode. a block diagram of a trigger circuit is shown in figure 12-19. the user specifies a match value in the trigx register. when the local time base counter value matches the trigx value, an adc trigger signal is generated. trigger signals are always generated regardless of the trigx value as long as the trigx value is less than or equal to the pwm period value for the local time base. if the trgien bit is set in the pwmconx register, then an interrupt request is generated. the individual trigger outputs can be divided per the trgdiv<2:0> bits in the trgconx registers, which allows the trigger signals to the adc to be generated once for every 1, 2, 3 ..., 7 trigger events. the trigger divider allows the user to tailor the adc sample rates to the requirements of the control loop. 12.18 time base capture with external trigger an external current-limit trigger signal will capture the pwm time base value and store it in the trgconx register. this feature can be used to monitor the time when an inductor current has reached a specified value.
? 2006 microchip technology inc. advance information ds70178a-page 133 dspic30f1010/202x figure 12-19: pwm trigger block diagram 12.19 pwm interrupts the pwm module can generate interrupts based on internal timing or based on external signals via the cur- rent-limit and fault inputs. the primary time base mod- ule can generate an interrupt request when a special event occurs. each pwm generator module has its own interrupt request signal to the interrupt controller. the interrupt for each pwm generator is an or of the trigger event interrupt request, the current-limit input event, or the fault input event for that module. there are four interrupt request signals to the interrupt control plus another interrupt request from the primary time base on special events. 12.20 pwm time base interrupts the pwm module can generate interrupts based on the primary time base and/or the individual time bases in each pwm generator. the interrupt timing is speci- fied by the special event comparison register (sevtcmp) for the primary time base, and by the trigx registers for the individual time bases in the pwm generator modules. the primary time base special event interrupt is enabled via the seien bit in the ptcon register. the individual time base interrupts generated by the trigger logic in each pwm generator are controlled by the trgien bit in the pwmconx registers. 12.21 pwm fault and current-limit pins the pwm module supports multiple fault pins for each pwm generator. these pins are labeled sfltx (shared fault) or ifltx (individual fault). the shared fault pins can be seen and used by any of the pwm generators. the individual fault pins are usable by specific pwm generators. each pwm generator can have one pin for use as a cycle-by-cycle current limit, and another pin for use as either a cycle-by-cycle current limit or a latching current fault disable function. 12.22 leading edge blanking each pwm generator supports ?leading edge blank- ing? of the current-limit and fault inputs via the leb<9:3> bits and the phr, phf, plr, plf, fltle- ben and clleben bits in the lebconx registers. the purpose of leading edge blanking is to mask the transients that occur on the application printed circuit board when the power transistors are turned on and off. the leb bits support the blanking (ignoring) of the cur- rent-limit and fault inputs for a period of 0 to 1024 nsec in 8.4 nsec increments following any specified rising or falling edge of the coarse pwmh and pwml signals. the coarse pwm signal (signal prior to the pwm fine tuning) has resolution of 8.4 nsec (at 30 mips), which is the same time resolution as the leb counters. the phr, phf, plr and plf bits select which edge of the pwmh and plwl signals will start the blanking timer. if a new selected edge triggers the leb timer while the timer is still active from a previously selected pwm edge, the timer reinitializes and continues counting. ptmrx compare logic 4 15 clk = trigx register trgdiv<2:0> pulse divider pwmx trigger 15 4 pdi pdi trigx write
dspic30f1010/202x ds70178a-page 134 advance information ? 2006 microchip technology inc. the fltleben and clleben bits enable the applica- tion of the blanking period to the selected fault and current-limit inputs. the leb duration @ 30 mips = (leb<9:3> + 1) / 120 mhz . there is a blanking period offset of 8.4 nsec. therefore a leb<9:3> value of zero yields an effective blanking period of 8.4 ns. if a current-limit or fault inputs are active at the end of the previous pwm cycle, and they are still active at the start of the new pwm cycle and the dead time is non- zero, the fault or current limit will be detected regardless of the leb counter configuration. 12.23 pwm fault pins each pwm generator can select its own fault input source from a selection of up to 12 fault/current-limit pins. in the fclconx registers, each pwm generator has control bits that specify the source for its fault input signal. these are the fltsrc<3:0> bits. additionally, each pwm generator has a fltien bit in the pwm- conx register that enables the generation of fault interrupt requests. each pwm generator has an asso- ciated fault polarity bit (fltpol) in the fclconx reg- ister that selects the active level of the selected fault input. the fault pins actually serve two different purposes. first is generation of fault overrides for the pwm out- puts. the action of overriding the pwm outputs and generating an interrupt is performed asynchronously in hardware so that fault events can be managed quickly. second, the fault pin inputs can be used to implement either current-limit pwm mode or current force mode. pwm fault condition states are available on the flt- stat bit in the pwmconx registers. the fltstat bits displays the fault irq latch if the fie bit is set. if fault interrupts are not enabled, then the fstatx bits display the status of the selected fltx input in positive logic format. when the fault input pins are not used in asso- ciation with a pwm generator, these pins become general purpose i/o or interrupt input pins. the fltx pins are normally active high. the fltpol bit in fclconx registers, if set to one, invert the selected fault input signal so that it is an active low. the fault pins are also readable through the port i/o logic when the pwm module is enabled. this allows the user to poll the state of the fault pins in software. 12.23.1 fault interrupts the fltienx bits in the pwmconx registers deter- mine if an interrupt will be generated when the fltx input is asserted high. the fltmod bits in the fclconx register determines how the pwm genera- tor and its outputs respond to the selected fault input pin. the fltdat<1:0> bits in the ioconx registers supply the data values to be assigned to the pwmxh,l pins in the advent of a fault. the fault pin logic can operate separately from the pwm logic as an external interrupt pin. if the faults are disabled from affecting the pwm generators in the fclconx register, then the fault pin can be used as a general purpose interrupt pin. 12.23.2 fault states the ioconx register has two bits that determine the state of each pwmx i/o pin when they are overridden by a fault input. when these bits are cleared, the pwm i/o pin is driven to the inactive state. if the bit is set, the pwm i/o pin is driven to the active state. the active and inactive states are referenced to the polarity defined for each pwm i/o pin (hpol and lpol polarity control bits). 12.23.3 fault input modes the fault input pin has two modes of operation: ? latched mode: when the fault pin is asserted, the pwm outputs go to the states defined in the fltdat bits in the ioconx registers. the pwm outputs remain in this state until the fault pin is deasserted and the corresponding interrupt flag has been cleared in software. when both of these actions have occurred, the pwm outputs return to normal operation at the beginning of the next pwm cycle boundary. if the fltstat bit is cleared before the fault condition ends, the pwm module waits until the fault pin is no longer asserted to restore the outputs. software can clear the fltstat bit by writing a zero to the fltien bit. ? cycle-by-cycle mode: when the fault input pin is asserted, the pwm outputs remain in the deas- serted pwm state for as long as the fault pin is asserted. for complementary output modes, pwmh is low (deasserted) and pwml is high (asserted). after the fault pin is driven high, the pwm outputs return to normal operation at the beginning of the following pwm cycle. the operating mode for each fault input pin is selected using the fltmod<1:0> control bits in the fclconx register. 12.23.4 fault entry the response of the pwm pins to the fault input pins is always asynchronous with respect to the device clock signals. that is, the pwm outputs should imme- diately go to the states defined in the fltdat register bits without any interaction from the dspic dsc device or software.
? 2006 microchip technology inc. advance information ds70178a-page 135 dspic30f1010/202x refer to section 12.28 ?fault and current-limit override issues with dead-time logic? for informa- tion regarding data sensitivity and behavior in response to current-limit or fault events. 12.23.5 fault exit the restoration of the pwm signals after a fault condi- tion has ended must occur at a pwm cycle boundary to ensure proper synchronization of pwm signal edges and manual signal overrides. the next pwm cycle begins when the ptmrx value is zero. 12.23.6 fault exit with ptmr disabled there is a special case for exiting a fault condition when the pwm time base is disabled (pten = 0). when a fault input is programmed for cycle-by-cycle mode, the pwm outputs are immediately restored to normal operation when the fault input pin is deas- serted. the pwm outputs should return to their default programmed values. (the time base is disabled, so there is no reason to wait for the beginning of the next pwm cycle.) when a fault input is programmed for latched mode, the pwm outputs are restored immediately when the fault input pin is deasserted and the fstat bit has been cleared in software. 12.23.7 fault pin software control the fault pin can be controlled manually in software. since the fault input is shared with a port i/o pin, the port pin can be configured as an output by clearing the corresponding tris bit. when the port bit for the pin is cleared, the fault input will be activated. 12.24 pwm current-limit pins each pwm generator can select its own current-limit input source from up to12 current-limit/fault pins. in the fclconx registers, each pwm generator has control bits (clsrc<3:0>) that specify the source for its cur- rent-limit input signal. additionally, each pwm genera- tor has a clien bit in the pwmconx register that enables the generation of current-limit interrupt requests. each pwm generator has an associated fault polarity bit clpol in the fclconx register. the current-limit pins actually serve two different pur- poses. they can be used to implement either current- limit pwm mode or current reset pwm mode. 1. when the clien bit is set in the pwmconx registers, the pwmxh,l outputs are forced to the values specified by the cldat<1:0> bits in the ioconx register, if the selected current-limit input signal is asserted. 2. when the clmod bit is zero and the xpres bit in the pwmconx register is ? 01 ? and the pwm generator is in independent time base mode ( itb = 1 ), then a current-limit signal resets the time base for the affected pwm gen- erator. this behavior is called current reset mode, which is used in some power factor correction (pfc) applications. 12.24.1 current-limit interrupts the state of the pwm current-limit conditions is avail- able on the clstat bits in the pwmconx registers. the clstat bits display the current-limit irq flag if the clien bit is set. if current-limit interrupts are not enabled, then the clstat bits display the status of the selected current-limit inputs in positive logic format. when the current-limit input pin associated with a pwm generator is not used, these pins become general purpose i/o or interrupt input pins. the current-limit pins are normally active high. if set to ? 1 ?, the clpol bit in fclconx registers inverts the selected current-limit input signal to active high. the interrupts generated by the selected current-limit signals are combined to create a single interrupt request signal to the interrupt controller, which has its own interrupt vector, interrupt flag bit, interrupt enable bit and interrupt priority bits associated with it. the fault pins are also readable through the port i/o logic when the pwm module is enabled. this allows the user to poll the state of the fault pins in software. 12.25 simultaneous pwm faults and current limits the current-limit override function, if enabled and active, forces the pwmxh,l pins to the values speci- fied by the cldat<1:0> bits in the ioconx registers unless the fault function is enabled and active. if the selected fault input is active, the pwmxh,l outputs assume the values specified by the fltdat<1:0> bits in the ioconx registers. 12.26 pwm fault and current-limit trg outputs to adc the fault and current-limit source selection fields in the fclconx registers (fltsrc<3:0> and clsrc<3:0>) control multiplexers in each pwm generator module. the control multiplexers select the desired fault and current-limit signals for their respective modules. the selected fault and current-limit signals are also avail- able to the adc module as trigger signals that initiate adc sampling and conversion operations. note: the user should use caution when control- ling the fault inputs in software. if the tris bit for the fault pin is cleared and the port bit is set high, then the fault input cannot be driven externally.
dspic30f1010/202x ds70178a-page 136 advance information ? 2006 microchip technology inc. 12.27 pwm output override priority if the pwm module is enabled, the priority of pwmx pin ownership is: 1. pwm generator (lowest priority) 2. output override 3. current-limit override 4. fault override 5. penx (gpio/pwm) ownership (highest priority) if the pwm module is disabled, the gpio module controls the pwmx pins. 12.28 fault and current-limit override issues with dead-time logic the pwmxh and pwmxl outputs are immediately driven low (deasserted) as specified by the cldat<1:0> and the fltdat<1:0> bits when a current-limit or a fault event occurs. the override data is gated with the pwm signals going into the dead-time logic block, and at the output of the pwm module, just ahead of the pwm pin output buffers. many applications require fast response to current shutdown for accurate current control and/or to limit circuitry damage to fault currents. some applications will set the complementary pwm outputs high in synchronous rectifier designs when a fault or current-limit event occurs. if the cldat or fltdat bits are set to ? 1 ?, and their associated event occurs, then these asserted outputs will be delayed by clocked logic in the dead-time circuitry. 12.29 asserting outputs via current limit it is possible to use the cldat bits to assert the pwmxh,l outputs in response to a current-limit event. such behavior could be used as a current ?force? fea- ture in response to an external current or voltage mea- surement that indicates a sudden sharp increase in the load on the power-converter output. forcing the pwm ?on? could be viewed as a ?feed-forward? term that allows quick system response to unexpected load increases without waiting for the digital control loop to respond. 12.30 pwm immediate update for high-performance pwm control-loop applications, the user may want to force the duty cycle updates to occur immediately. setting the iue bit in the pwmconx register enables this feature. in a closed-loop control application, any delay between the sensing of a system?s state and the subsequent outputting of pwm control signals that drive the appli- cation reduces the loop stability. setting the iue bit minimizes the delay between writing the duty cycle reg- isters and the response of the pwm generators to that change. 12.31 pwm output override all control bits associated with the pwm output override function are contained in the ioconx register. if the penh, penl bits are reset (default state), then the pwm module controls the pwmx output pins. the pwm output override bits allow the user to manu- ally drive the pwm i/o pins to specified logic states independent of the duty cycle comparison units. the ovrdat<1:0> bits in the ioconx register deter- mine the state of the pwm i/o pins when a particular output is overridden via the ovrenh,l bits. the ovrenh, ovrenl bits are active high control bits. when the ovren bits are set, the corresponding ovrdat bit overrides the pwm output from the pwm generator. 12.31.1 complementary output mode when the pwm is in complementary output mode, the dead-time generator is still active with overrides. the output overrides and fault overrides generate control signals used by the dead-time unit to set the outputs as requested, including dead time. dead-time insertion can be performed when pwm channels are overridden manually. 12.31.2 override synchronization if the osync bit in the ioconx register is set, the out- put overrides performed via the ovrenh,l and the ovddat<1:0> bits are synchronized to the pwm time base. synchronous output overrides occur when the time base is zero. if pten = 0 , meaning the timer is not running, writes to iocon take effect on the next t cy boundary. 12.32 functional exceptions 12.32.1 power reset conditions all registers associated with the pwm module are reset to the states given in table 12-4 upon a power-on reset. on a device reset, the pwm output pins are tri-stated. 12.32.2 sleep mode the selected fault input pin has the ability to wake the cpu from sleep mode. the pwm module should gen- erate an asynchronous interrupt if any of the selected fault pins is driven low while in sleep. it is recommended that the user disable the pwm out- puts prior to entering sleep mode. if the pwm module is controlling a power conversion application, the action
? 2006 microchip technology inc. advance information ds70178a-page 137 dspic30f1010/202x of putting the device into sleep will cause any control loops to be disabled, and most applications will likely experience issues unless they are explicitly designed to operate in an open-loop mode. 12.32.3 cpu idle mode the dspic30f1010/202x module has a ptsidl con- trol bit in the ptcon register. this bit determines if the pwm module continues to operate or stops when the device enters idle mode. stopped idle mode functions like sleep mode, and fault pins are asynchronously active. ? ptsidl = 1 (stop module when in idle mode) ? ptsidl = 0 (don't stop module when in idle mode) it is recommended that the user disable the pwm out- puts prior to entering idle mode. if the pwm module is controlling a power-conversion application, the action of putting the device into idle will cause any control loops to be disabled, and most applications will likely experience issues unless they are explicitly designed to operate in an open-loop mode. 12.33 register bit alignment table 12-4 on page 143 shows the registers for the smps pwm module. all time-based data for the mod- ule is always bit-aligned with respect to time. for exam- ple: bit 3 in the period register, the duty cycle registers, the dead-time registers, the trigger registers and the phase registers always represents a value of 18.4 nsec, assuming 30 mips operation. unused portions of registers always read as zeros. the use of data alignment makes it easier to write soft- ware because it eliminates the need to shift time values to fit into registers. it also eases the computation and understanding of time allotment within a pwm cycle.
dspic30f1010/202x ds70178a-page 138 advance information ? 2006 microchip technology inc. 12.34 application examples: 12.34.1 standard pwm mode in standard pwm mode, the pwm output is typically connected to a single transistor, which charges an inductor, as shown in figure 12-20. buck and boost converters typically use standard pwm mode. figure 12-20: applications of standard pwm mode 12.34.2 application of complementary pwm mode complementary mode pwm is often used in circuits that use two transistors in a bridge configuration where transformers are not used, as shown in figure 12-21. if transformers are used, then some means must be provided to ensure that no net dc currents flow through the transformer to prevent core saturation. figure 12-21: applications of complementary pwm mode buck converter +v in l1 pwm1h + v out boost converter +v in pwm1h l1 v out + period pwm1h t on t off inductor charges during t on t on versus period controls power flow v out l1 +v in pwm1h pwm1l synchronous buck converter + + +v in pwm1h pwm1l c r t1 series resonant half bridge converter l r v out pwm1l pwm1h dead time dead time dead time period
? 2006 microchip technology inc. advance information ds70178a-page 139 dspic30f1010/202x 12.34.3 application of push-pull pwm mode push-pull pwm mode is typically used in transformer coupled circuits to ensure that no net dc currents flow through the transformer. push-pull mode ensures that the same duty cycle pwm pulse is applied to the transformer windings in alternate directions, as shown in figure 12-22. figure 12-22: applications of push- pull pwm mode 12.34.4 application of multi-phase pwm mode multi-phase pwm mode is often used in dc/dc con- verters that must handle very fast load current tran- sients and fit into tight spaces. a multi-phase converter is essentially a parallel array of buck converters that are operated slightly out of phase of each other, as shown in figure 12-23. the multiple phases create an effective switching speed equal to the sum of the indi- vidual converters. if a single phase is operating with a 333 khz pwm frequency, then the effective switching frequency for the circuit is 1 mhz. this high switching frequency greatly reduces output capacitor size requirements and improves load transient response. figure 12-23: applications of multi- phase pwm mode + t1 v out half bridge converter +v in pwm1h pwm1l + + l1 pwm1h pwm1l t on t off t on t off period period dead time dead time dead time t1 + +v in pwm1h pwm1l push-pull buck converter l1 v out pwh1h pwh1l pwh1l pwh1h +v in t1 l1 v out full bridge converter + + + v in pwm1h pwm2h pwm3h l1 l2 l3 pwm1l pwm1l pwm1l v out converter multiphase dc/dc pwm1h pwm1l pwm2h pwm2l pwm3h pwm3l
dspic30f1010/202x ds70178a-page 140 advance information ? 2006 microchip technology inc. 12.34.5 application of variable phase pwm mode variable phase pwm is used in newer power conver- sion topologies that are designed to reduce switching losses. in standard pwm methods, any time a transis- tor switches between the conducting state and the nonconducting state (and vice versa), the transistor is exposed to the full current and voltage condition for the period of time it takes the transistor to turn on or off. the power loss (v * i * tsw * fpwm) becomes appreciable at high frequencies. the zero voltage switching (zvs) and zero current switching (zvc) cir- cuit topologies attempt to use quasi-resonant tech- niques to shift either the voltage or current waveforms relative to each other. this action either makes the voltage or the current zero at the time the transistor turns on or off. if either the current or the voltage is zero, then there is no switching loss generated. in variable phase pwm modes, the duty cycle is fixed at 50%, and the power flow is controlled by varying the phase relationship between the pwm channels, as shown in figure 12-24. figure 12-24: application of variable phase pwm mode 12.34.6 application of current reset pwm mode in current reset pwm mode, the pwm frequency var- ies with the load current. this mode is different than most pwm modes because the user sets the maxi- mum pwm period, but an external circuit measures the inductor current. when the inductor current falls below a specified value, the external current compara- tor circuit generates a signal that resets the pwm time base counter. the user specifies a pwm ?on? time, and then some time after the pwm signal becomes inactive, the inductor current falls below a specified value and the pwm counter is reset earlier than the programmed pwm period. this mode is sometimes called constant on-time. this mode should not be confused with cycle-by-cycle current-limiting pwm, where the pwm is asserted, an external circuit generates a current fault and the pwm signal is turned off before its programmed duty cycle would normally turn it off. in this mode, shown in figure 12-25, the pwm frequency is fixed per the time base period. figure 12-25: application of current reset pwm mode pwm1h pwm1l pwm2h pwm2l variable phase shift + full bridge zvt converter t1 v out +v in pwm1h pwm1h pwm1h pwm1h + + ac in c in l i l pwm1h d v out c out external current comparator resets pwm counter pwm cycle restarts early this is a variable frequency pwm mode pwm1h pwm1h i l t on t off actual period programmed period
? 2006 microchip technology inc. advance information ds70178a-page 141 dspic30f1010/202x 12.35 methods to reduce emi the goal is to move the pwm edges around in time to spread the emi energy over a range of frequencies to reduce the peak energy at any given frequency during the emi measurement process, which measures long term averages. the emi measurement process integrates the emi energy into 9 khz wide frequency bins. assuming that the carrier (pwm) frequency is 150 khz, a 6% dither will yield a 9 khz wide dither. 12.35.1 method #1: programmable frc dither this method dithers all of the pwm outputs and the system clock. the advantage of this method is that no cpu resources are required. it is automatic once it is setup. the user can periodically update these values to simulate a more random frequency pattern. 12.35.2 method #2: software controlled dither this method uses software to dither individual pwm channels by scaling the duty cycle and period. this method consumes cpu resources: assume: 4 pwm channels updated @ 150 khz rate: 600 khz x (5 clocks (2 mul, 1 tblrdl, 1 mov)) = 3 mips additional work load 12.35.3 method #3: software scaling of time base period this method used software to scale just the time base period. assuming that the dither rate is relatively slow (about 250 hz), the application control loop should be able to compensate for the changes in pwm period and adjust the duty cycle accordingly. 12.35.4 method #4: frequency modulation this method varies the frequency at which the pwm cycle is varied (dithered). the frequency modulation process is similar (mathematically speaking) to phase modulation when analyzed over a small time window. the pwm module has the capability to phase modu- late the pwm signals via the phase offset registers. phase modulation has the advantage that the software is simpler and faster because multiple multiply opera- tions (used for dithering frequency by scaling period and duty cycles) are replaced with fewer additions or simple updates of phase offset values into the phase registers. this method also has these advantages: 1. multi-phase and variable phase pwm modes could still be created. 2. the pwm generators can still use the common time base, which simplifies determining when a ?quiet time? is available for measuring current. this method has one disadvantage: the phase modu- lation has to be at a relatively high update rate to achieve usable frequency spreading. 12.35.5 independent pwm channel dithering issues: issues for multi-phase or variable phase designs using independent output dithering must consider these issues: 1. the phases are no longer phase aligned. 2. control of current sharing among phases is more difficult.
dspic30f1010/202x ds70178a-page 142 advance information ? 2006 microchip technology inc. 12.36 external synchronization features in large power conversion systems, it is often desir- able to be able to synchronize multiple power control- lers to ensure that ?beat frequencies? are not generated within the system, or as a means to ensure ?quiet? periods during which current and voltage mea- surements can be made. dspic30f202x devices (excluding 28-pin packages) have input and/or output pins that provide the capabil- ity to either synchronize the smps dspic dsc device with an external device or have external devices syn- chronized to the smps dspic dsc. these synchro- nizing features are enabled via the syncien and syncoen bits in the ptcon control register in the pwm module. the syncpol bit in the ptcon register selects whether the rising edge or the falling edge of the synci signal is the active edge. the syncpol bit in the ptcon register also selects whether the synco output pulse is low active or high active. the syncsrc<2:0> bits in the ptcon register specify the source for the synci signal. if the synci feature is enabled, the primary time base counter is reset when an active synci edge is detected. if the synco feature is enabled, an output pulse is generated when the primary time base counter rolls over at the end of a pwm cycle. the recommended synci pulse width should be more than 100 nsec. the expected synco output pulse width will be approximately 100 nsec. when using the synci feature, it is recommended that the user program the period register with a period value that is slightly longer than the expected period of the external synchronization input signal. this pro- vides protection in case the synci signal is not received due to noise or external component failure. with a reasonable period value programmed into the period register, the local power conversion process should remain operational even if the global synchronization signal is not received. 12.37 timing external pwm trigger events the trgconx control registers provide the capability to capture the time base value of an individual pwm generator at the moment a selected external trigger signal is detected. this timing information is useful in many applications where external circuitry is monitor- ing current or voltage. the software may want to deter- mine if the external trigger event occurred either too early or too late. 12.38 cpu load staggering the smps dspic dsc has the ability to stagger the individual trigger comparison operations. this feature helps to level the processor?s workload to minimize situations where the processor is overloaded. assume a situation where there are four pwm chan- nels controlling four independent voltage outputs. assume further that each pwm generator is operating at 1000 khz (1 sec period) and each control loop is operating at 125 khz (8 sec). the tdiv<2:0> bits in each pwmconx register will be set to ? 111 ?, which selects that every 8th trigger comparison match will generate a trigger signal to the adc to capture data and begin a conversion process. if the stagger-in-time feature did not exist, all of the requests from all of the pwm trigger registers might occur at the same time. if this ?pile-up? were to hap- pen, some data sample might become stale (outdated) by the time the data for all four channels can be processed. with the stagger-in-time feature, the trigger signals are spaced out over time (during succeeding pwm peri- ods) so that all of the data is processed in an orderly manner. the roll counter is a counter connected to the pri- mary time base counter. the roll counter is incre- mented each time the primary time base counter reaches terminal count (period rollover). the stagger-in-time feature is controlled by the trgstrt<5:0> bits in the trgconx registers. the trgstrt<5:0> bits specify the count value of the roll counter that must be matched before an individ- ual trigger comparison module in each of the pwm generators can begin to count the trigger comparison events as specified by the trgdiv<2:0> bits in the pwmconx registers. so, in our example with the four pwm generators, the first pwm?s trgstrt<5:0> bits would be ? 000 ?, the second pwm?s trgstrt bits would be set to ? 010 ?, the third pwm?s trgstrt bits would be set to ? 100 ? and the fourth pwm?s trgstrt bits would be set to ? 110 ?. therefore, over a total of eight pwm cycles, the four separate control loops could be run each with their own 2-sec time period. 12.39 external trigger blanking using the leb<9:3> bits in the lebconx registers, the pwm module has the capability to blank (ignore) the external current and fault inputs for a period of 0 to 1024 nsec. this feature is useful if power transistor turn-on induced transients make current sensing difficult at the start of a pwm cycle.
? 2006 microchip technology inc. advance information ds70178a-page 143 dspic30f1010/202x table 12-4: smps pwm register map file name adr bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 b it 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ptcon 0400 pten ? ptsidl sestat seien eipu syncpol syncoen syncen syncsrc<2:0> sevtps<3:0> 0000 ptper 0402 ptper<15:3> ? ? ? fff0 mdc 0404 mdc<15:0> 0000 sevtcmp 0406 sevtcmp<15:3> ? ? ? 0000 pwmcon1 0408 fltstat clstat trgstat fltien clien trgien itb mdcs dtc<1:0> ? ? ? ? xpres iue 0000 iocon1 040a penh penl polh poll pmod<1:0> ovrenh ovrenl ovrdat<1:0> fltdat<1:0> cldat<1:0> ? osync 0000 fclcon1 040c ? ? ? clsrc<3:0> clpol clmod fltsrc<3:0> fltpol fltmod<1:0> 0000 pdc1 040e pdc1<15:0> 0000 phase1 0410 phase1<15:2> ? ? 0000 dtr1 0412 ? ?dtr1<13:2> ? ? 0000 altdtr1 0414 ? ? altdtr1<13:2> ? ? 0000 trig1 0416 trig<15:3> ? ? ? 0000 trgcon1 0418 trgdiv<2:0> ?- ?- ?- ?- ?- ?- ?- trgstrt<5:0> 0000 lebcon1 041a phr phf plr plf fltleben clleben leb<9:3> ? ? ? 0000 pwmcon2 041c fltstat clstat trgstat fltien clien trgien itb mdcs dtc<1:0> ? ? ? ? xpres iue 0000 iocon2 041e penh penl polh poll pmod<1:0> ovrenh ovrenl ovrdat<1:0> fltdat<1:0> cldat<1:0> ? osync 0000 fclcon2 0420 ? ? ? clsrc<3:0> clpol clmod fltsrc<3:0> fltpol fltmod<1:0> 0000 pdc2 0422 pdc2<15:0> 0000 phase2 0424 phase2<15:2> ? ? 0000 dtr2 0426 ? ?dtr2<13:2> ? ? 0000 altdtr2 0428 ? ? altdtr2<13:2> ? ? 0000 trig2 042a trig<15:3> ? ? ? 0000 trgcon2 042c trgdiv<2:0> ?- ?- ?- ?- ?- ?- ?- trgstrt<5:0> 0000 lebcon2 042e phr phf plr plf fltleben clleben leb<9:3> ? ? ? 0000 pwmcon3 0430 fltstat clstat trgstat fltien clien trgien itb mdcs dtc<1:0> ? ? ? ? xpres iue 0000 iocon3 0432 penh penl polh poll pmod<1:0> ovrenh ovrenl ovrdat<1:0> fltdat<1:0> cldat<1:0> ? osync 0000 fclcon3 0434 ? ? ? clsrc<3:0> clpol clmod fltsrc<3:0> fltpol fltmod<1:0> 0000 pdc3 0436 pdc3<15:0> 0000 phase3 0438 phase3<15:2> ? ? 0000 dtr3 043a ? ?dtr3<13:2> ? ? 0000 altdtr3 043c ? ? altdtr3<13:2> ? ? 0000 trig3 043e trig<15:3> ? ? ? 0000 trgcon3 0440 trgdiv<2:0> ?- ?- ?- ?- ?- ?- ?- trgstrt<5:0> 0000 lebcon3 0442 phr phf plr plf fltleben clleben leb<9:3> ? ? ? 0000 pwmcon4 0444 fltstat clstat trgstat fltien clien trgien itb mdcs dtc<1:0> trgdiv<2:0> trgmod xpres iue 0000 iocon4 0446 penh penl polh poll pmod<1:0> ovrenh ovrenl ovrdat<1:0> fltdat<1:0> cldat<1:0> ? osync 0000
dspic30f1010/202x ds70178a-page 144 advance information ? 2006 microchip technology inc. fclcon4 0448 ? ? ? clsrc<3:0> clpol clmode fltsrc<3:0> fltpol fltmod<1:0> 0000 pdc4 044a pdc4<15:0> 0000 phase4 044c phase4<15:2> ? ? 0000 dtr4 044e ? ? dtr4<13:2> ? ? 0000 altdtr4 0450 ? ? altdtr4<13:2> ? ? 0000 trig4 0452 trig<15:3> ? ? ? 0000 trgcon4 0454 trgdiv<2:0> ?- ?- ?- ?- ?- ?- ?- trgstrt<5:0> 0000 lebcon4 0456 phr phf plr plf fltleben clleben leb<9:3> ? ? ? 0000 reserved 0458- 47f ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0000 table 12-4: smps pwm register map (continued)
? 2006 microchip technology inc. advance information ds70178a-page 145 dspic30f1010/202x 13.0 spi module the serial peripheral interface (spi) module is a syn- chronous serial interface. it is useful for communicating with other peripheral devices such as eeproms, shift registers, display drivers and a/d converters, or other microcontrollers. it is compatible with motorola's spi and siop interfaces. 13.1 operating function description each spi module consists of a 16-bit shift register, spixsr (where x = 1 or 2), used for shifting data in and out, and a buffer register, spixbuf. a control reg- ister, spixcon, configures the module. additionally, a status register, spixstat, indicates various status conditions. the serial interface consists of 4 pins: sdix (serial data input), sdox (serial data output), sckx (shift clock input or output), and ssx (active low slave select). in master mode operation, sck is a clock output, but in slave mode, it is a clock input. a series of eight (8) or sixteen (16) clock pulses shifts out bits from the spixsr to sdox pin and simulta- neously shifts in data from sdix pin. an interrupt is generated when the transfer is complete and the cor- responding interrupt flag bit (spi1if or spi2if) is set. this interrupt can be disabled through an interrupt enable bit (spi1ie or spi2ie). the receive operation is double-buffered. when a complete byte is received, it is transferred from spixsr to spixbuf. if the receive buffer is full when new data is being transferred from spixsr to spixbuf, the module will set the spirov bit, indicating an overflow condition. the transfer of the data from spixsr to spixbuf will not be completed and the new data will be lost. the module will not respond to scl transitions while spirov is 1 , effectively disabling the module until spixbuf is read by user software. transmit writes are also double-buffered. the user writes to spixbuf. when the master or slave transfer is completed, the contents of the shift register (spixsr) is moved to the receive buffer. if any trans- mit data has been written to the buffer register, the contents of the transmit buffer are moved to spixsr. the received data is thus placed in spixbuf and the transmit data in spixsr is ready for the next transfer. in master mode, the clock is generated by prescaling the system clock. data is transmitted as soon as a value is written to spixbuf. the interrupt is generated at the middle of the transfer of the last bit. in slave mode, data is transmitted and received as external clock pulses appear on sck. again, the inter- rupt is generated when the last bit is latched. if ssx control is enabled, then transmission and reception are enabled only when ssx = low. the sdox output will be disabled in ssx mode with ssx high. the clock provided to the module is (f osc / 2). this clock is then prescaled by the primary (ppre<1:0>) and the secondary (spre<2:0>) prescale factors. the cke bit determines whether transmit occurs on transi- tion from active clock state to idle clock state, or vice versa. the ckp bit selects the idle state (high or low) for the clock. 13.1.1 word and byte communication a control bit, mode16 (spixcon<10>), allows the module to communicate in either 16-bit or 8-bit mode. 16-bit operation is identical to 8-bit operation, except that the number of bits transmitted is 16 instead of 8. the user software must disable the module prior to changing the mode16 bit. the spi module is reset when the mode16 bit is changed by the user. a basic difference between 8-bit and 16-bit operation is that the data is transmitted out of bit 7 of the spixsr for 8-bit operation, and data is transmitted out of bit 15 of the spixsr for 16-bit operation. in both modes, data is shifted into bit 0 of the spixsr. 13.1.2 sdox disable a control bit, dissdo, is provided to the spixcon reg- ister to allow the sdox output to be disabled. this will allow the spi module to be connected in an input only configuration. sdo can also be used for general purpose i/o. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). note: the dspic30f1010/202x family has only one spi module. all references to x = 2 are intended for software compatibility with other dspic dsc devices. note: if the module is used in a transmit only configuration, the user application must perform a read of the spxbuf to avoid a receive overflow condition ( spirov = 1 ). note: both the transmit buffer (spixtxb) and the receive buffer (spixrxb) are mapped to the same register address, spixbuf.
dspic30f1010/202x ds70178a-page 146 advance information ? 2006 microchip technology inc. 13.2 framed spi support the module supports a basic framed spi protocol in master or slave mode. the control bit frmen enables framed spi support and causes the ssx pin to perform the frame synchronization pulse (fsync) function. the control bit spifsd determines whether the ssx pin is an input or an output (i.e., whether the module receives or generates the frame synchronization pulse). the frame pulse is an active high pulse for a sin- gle spi clock cycle. when frame synchronization is enabled, the data transmission starts only on the subsequent transmit edge of the spi clock. figure 13-1: spi block diagram figure 13-2: spi master/slave connection note: x = 1 or 2. read write internal data bus sdix sdox ssx sckx spixsr spixbuf bit0 shift clock edge select f cy primary 1:1, 1:4, enable master clock prescaler secondary prescaler 1:1-1:8 ss & fsync control clock control transmit spixbuf receive 1:16, 1:64 serial input buffer (spixbuf) shift register (spixsr) msb lsb sdox sdix processor 1 sckx spi master serial input buffer (spiybuf) shift register (spiysr) lsb msb sdiy sdoy processor 2 scky spi slave serial clock note: x = 1 or 2, y = 1 or 2.
? 2006 microchip technology inc. advance information ds70178a-page 147 dspic30f1010/202x 13.3 slave select synchronization the ssx pin allows a synchronous slave mode. the spi must be configured in spi slave mode, with ssx pin control enabled (ssen = 1 ). when the ssx pin is low, transmission and reception are enabled, and the sdox pin is driven. when ssx pin goes high, the sdox pin is no longer driven. also, the spi module is re- synchronized, and all counters/control circuitry are reset. therefore, when the ssx pin is asserted low again, transmission/reception will begin at the most significant bit, even if ssx had been deasserted in the middle of a transmit/receive. 13.4 spi operation during cpu sleep mode during sleep mode, the spi module is shut-down. if the cpu enters sleep mode while an spi transaction is in progress, then the transmission and reception is aborted. the transmitter and receiver will stop in sleep mode. however, register contents are not affected by entering or exiting sleep mode. 13.5 spi operation during cpu idle mode when the device enters idle mode, all clock sources remain functional. the spisidl bit (spixstat<13>) selects if the spi module will stop or continue on idle. if spisidl = 0 , the module will continue to operate when the cpu enters idle mode. if spisidl = 1 , the module will stop when the cpu enters idle mode.
dspic30f1010/202x ds70178a-page 148 advance information ? 2006 microchip technology inc. table 13-1: spi1 register map note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields. sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state spi1stat 0240 spien ? spisidl ? ? ? ? ? ? spirov ? ? ? ? spitbf spirbf 0000 0000 0000 0000 spi1con 0242 ? frmen spifsd ? dissdo mode16 smp cke ssen ckp msten spre2 spre1 spre0 ppre1 ppre0 0000 0000 0000 0000 spi1buf 0244 transmit and receive buffer 0000 0000 0000 0000 legend: u = uninitialized bit
? 2006 microchip technology inc. advance information ds70178a-page 149 dspic30f1010/202x 14.0 i 2 c? module the inter-integrated circuit (i 2 c) module provides complete hardware support for both slave and multi- master modes of the i 2 c serial communication standard, with a 16-bit interface. this module offers the following key features: ?i 2 c interface supporting both master and slave operation. ?i 2 c slave mode supports 7 and 10-bit address ?i 2 c master mode supports 7 and 10-bit address ?i 2 c port allows bidirectional transfers between master and slaves. ? serial clock synchronization for i 2 c port can be used as a handshake mechanism to suspend and resume serial transfer (sclrel control). ?i 2 c supports multi-master operation; detects bus collision and will arbitrate accordingly. 14.1 operating function description the hardware fully implements all the master and slave functions of the i 2 c standard and fast mode specifications, as well as 7 and 10-bit addressing. thus, the i 2 c module can operate either as a slave or a master on an i 2 c bus. 14.1.1 various i 2 c modes the following types of i 2 c operation are supported: ?i 2 c slave operation with 7 or 10-bit address ?i 2 c master operation with 7 or 10-bit address see the i 2 c programmer?s model in figure 14-1. 14.1.2 pin configuration in i 2 c mode i 2 c has a 2-pin interface; pin scl is clock and pin sda is data. figure 14-1: programmer?s model 14.1.3 i 2 c registers i2ccon and i2cstat are control and status regis- ters, respectively. the i2ccon register is readable and writable. the lower 6 bits of i2cstat are read-only. the remaining bits of the i2cstat are read/write. i2crsr is the shift register used for shifting data, whereas i2crcv is the buffer register to which data bytes are written, or from which data bytes are read. i2crcv is the receive buffer, as shown in figure 16-1. i2ctrn is the transmit register to which bytes are writ- ten during a transmit operation, as shown in figure 16-2. the i2cadd register holds the slave address. a status bit, add10, indicates 10-bit address mode. the i2cbrg acts as the baud rate generator (brg) reload value. in receive operations, i2crsr and i2crcv together form a double-buffered receiver. when i2crsr receives a complete byte, it is transferred to i2crcv and an interrupt pulse is generated. during transmission, the i2ctrn is not double-buffered. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). bit 7 bit 0 i2crcv (8 bits) bit 7 bit 0 i2ctrn (8 bits) bit 8 bit 0 i2cbrg (9 bits) bit 15 bit 0 i2ccon (16 bits) bit 15 bit 0 i2cstat (16 bits) bit 9 bit 0 i2cadd (10 bits) note: following a restart condition in 10-bit mode, the user only needs to match the first 7-bit address.
dspic30f1010/202x ds70178a-page 150 advance information ? 2006 microchip technology inc. figure 14-2: i 2 c? block diagram i2crsr i2crcv internal data bus scl sda shift match detect i2cadd start and stop bit detect clock addr_match clock stretching i2ctrn lsb shift clock write read brg down i2cbrg reload control f cy start, restart, stop bit generate write read acknowledge generation collision detect write read write read i2ccon write read i2cstat control logic read lsb counter
? 2006 microchip technology inc. advance information ds70178a-page 151 dspic30f1010/202x 14.2 i 2 c module addresses the i2cadd register contains the slave mode addresses. the register is a 10-bit register. if the a10m bit (i2ccon<10>) is ? 0 ?, the address is interpreted by the module as a 7-bit address. when an address is received, it is compared to the 7 least significant bits of the i2cadd register. if the a10m bit is ? 1 ?, the address is assumed to be a 10-bit address. when an address is received, it will be compared with the binary value ? 1 1 1 1 0 a9 a8 ? (where a9, a8 are two most significant bits of i2cadd). if that value matches, the next address will be compared with the least significant 8 bits of i2cadd, as specified in the 10-bit addressing protocol. 14.3 i 2 c 7-bit slave mode operation once enabled (i2cen = 1 ), the slave module will wait for a start bit to occur (i.e., the i 2 c module is ?idle?). fol- lowing the detection of a start bit, 8 bits are shifted into i2crsr and the address is compared against i2cadd. in 7-bit mode (a10m = 0 ), bits i2cadd<6:0> are compared against i2crsr<7:1> and i2crsr<0> is the r_w bit. all incoming bits are sampled on the rising edge of scl. if an address match occurs, an acknowledgement will be sent, and the slave event interrupt flag (si2cif) is set on the falling edge of the ninth (ack ) bit. the address match does not affect the contents of the i2crcv buffer or the rbf bit. 14.3.1 slave transmission if the r_w bit received is a ? 1 ?, then the serial port will go into transmit mode. it will send ack on the ninth bit and then hold scl to ? 0 ? until the cpu responds by writ- ing to i2ctrn. scl is released by setting the sclrel bit, and 8 bits of data are shifted out. data bits are shifted out on the falling edge of scl, such that sda is valid during scl high (see timing diagram). the inter- rupt pulse is sent on the falling edge of the ninth clock pulse, regardless of the status of the ack received from the master. 14.3.2 slave reception if the r_w bit received is a ? 0 ? during an address match, then receive mode is initiated. incoming bits are sampled on the rising edge of scl. after 8 bits are received, if i2crcv is not full or i2cov is not set, i2crsr is transferred to i2crcv. ack is sent on the ninth clock. if the rbf flag is set, indicating that i2crcv is still holding data from a previous operation (rbf = 1 ), then ack is not sent; however, the interrupt pulse is gener- ated. in the case of an overflow, the contents of the i2crsr are not loaded into the i2crcv. 14.4 i 2 c 10-bit slave mode operation in 10-bit mode, the basic receive and transmit opera- tions are the same as in the 7-bit mode. however, the criteria for address match is more complex. the i 2 c specification dictates that a slave must be addressed for a write operation, with two address bytes following a start bit. the a10m bit is a control bit that signifies that the address in i2cadd is a 10-bit address rather than a 7-bit address. the address detection protocol for the first byte of a message address is identical for 7-bit and 10-bit messages, but the bits being compared are different. i2cadd holds the entire 10-bit address. upon receiv- ing an address following a start bit, i2crsr <7:3> is compared against a literal ? 11110 ? (the default 10-bit address) and i2crsr<2:1> are compared against i2cadd<9:8>. if a match occurs and if r_w = 0 , the interrupt pulse is sent. the add10 bit will be cleared to indicate a partial address match. if a match fails or r_w = 1 , the add10 bit is cleared and the module returns to the idle state. the low byte of the address is then received and com- pared with i2cadd<7:0>. if an address match occurs, the interrupt pulse is generated and the add10 bit is set, indicating a complete 10-bit address match. if an address match did not occur, the add10 bit is cleared and the module returns to the idle state. 14.4.1 10-bit mode slave transmission once a slave is addressed in this fashion, with the full 10-bit address (we will refer to this state as ?prior_addr_match?), the master can begin send- ing data bytes for a slave reception operation. 14.4.2 10-bit mode slave reception once addressed, the master can generate a repeated start, reset the high byte of the address and set the r_w bit without generating a stop bit, thus initiating a slave transmit operation. note: the i2crcv will be loaded if the i2cov bit = 1 and the rbf flag = 0 . in this case, a read of the i2crcv was performed, but the user did not clear the state of the i2cov bit before the next receive occurred. the acknowledgement is not sent (ack = 1 ) and the i2crcv is updated.
dspic30f1010/202x ds70178a-page 152 advance information ? 2006 microchip technology inc. 14.5 automatic clock stretch in the slave modes, the module can synchronize buffer reads and write to the master device by clock stretching. 14.5.1 transmit clock stretching both 10-bit and 7-bit transmit modes implement clock stretching by asserting the sclrel bit after the falling edge of the ninth clock if the tbf bit is cleared, indicating the buffer is empty. in slave transmit modes, clock stretching is always performed, irrespective of the stren bit. clock synchronization takes place following the ninth clock of the transmit sequence. if the device samples an ack on the falling edge of the ninth clock, and if the tbf bit is still clear, then the sclrel bit is automati- cally cleared. the sclrel being cleared to ? 0 ? will assert the scl line low. the user?s isr must set the sclrel bit before transmission is allowed to con- tinue. by holding the scl line low, the user has time to service the isr and load the contents of the i2ctrn before the master device can initiate another transmit sequence. 14.5.2 receive clock stretching the stren bit in the i2ccon register can be used to enable clock stretching in slave receive mode. when the stren bit is set, the scl pin will be held low at the end of each data receive sequence. 14.5.3 clock stretching during 7-bit addressing (stren = 1 ) when the stren bit is set in slave receive mode, the scl line is held low when the buffer register is full. the method for stretching the scl output is the same for both 7 and 10-bit addressing modes. clock stretching takes place following the ninth clock of the receive sequence. on the falling edge of the ninth clock at the end of the ack sequence, if the rbf bit is set, the sclrel bit is automatically cleared, forcing the scl output to be held low. the user?s isr must set the sclrel bit before reception is allowed to continue. by holding the scl line low, the user has time to service the isr and read the contents of the i2crcv before the master device can initiate another receive sequence. this will prevent buffer overruns from occurring. 14.5.4 clock stretching during 10-bit addressing (stren = 1 ) clock stretching takes place automatically during the addressing sequence. because this module has a register for the entire address, it is not necessary for the protocol to wait for the address to be updated. after the address phase is complete, clock stretching will occur on each data receive or transmit sequence as was described earlier. 14.6 software controlled clock stretching (stren = 1 ) when the stren bit is ? 1 ?, the sclrel bit may be cleared by software to allow software to control the clock stretching. the logic will synchronize writes to the sclrel bit with the scl clock. clearing the sclrel bit will not assert the scl output until the module detects a falling edge on the scl output and scl is sampled low. if the sclrel bit is cleared by the user while the scl line has been sampled low, the scl output will be asserted (held low). the scl out- put will remain low until the sclrel bit is set, and all other devices on the i 2 c bus have deasserted scl. this ensures that a write to the sclrel bit will not violate the minimum high time requirement for scl. if the stren bit is ? 0 ?, a software write to the sclrel bit will be disregarded and have no effect on the sclrel bit. 14.7 interrupts the i 2 c module generates two interrupt flags, mi2cif (i 2 c master interrupt flag) and si2cif (i 2 c slave inter- rupt flag). the mi2cif interrupt flag is activated on completion of a master message event. the si2cif interrupt flag is activated on detection of a message directed to the slave. note 1: if the user loads the contents of i2ctrn, setting the tbf bit before the falling edge of the ninth clock, the sclrel bit will not be cleared and clock stretching will not occur. 2: the sclrel bit can be set in software, regardless of the state of the tbf bit. note 1: if the user reads the contents of the i2crcv, clearing the rbf bit before the falling edge of the ninth clock, the sclrel bit will not be cleared and clock stretching will not occur. 2: the sclrel bit can be set in software, regardless of the state of the rbf bit. the user should be careful to clear the rbf bit in the isr before the next receive sequence in order to prevent an overflow condition.
? 2006 microchip technology inc. advance information ds70178a-page 153 dspic30f1010/202x 14.8 slope control the i 2 c standard requires slope control on the sda and scl signals for fast mode (400 khz). the control bit, disslw, enables the user to disable slew rate con- trol, if desired. it is necessary to disable the slew rate control for 1 mhz mode. 14.9 ipmi support the control bit ipmien enables the module to support intelligent peripheral management interface (ipmi). when this bit is set, the module accepts and acts upon all addresses. 14.10 general call address support the general call address can address all devices. when this address is used, all devices should, in theory, respond with an acknowledgement. the general call address is one of eight addresses reserved for specific purposes by the i 2 c protocol. it consists of all ? 0 ?s with r_w = 0 . the general call address is recognized when the gen- eral call enable (gcen) bit is set (i2ccon<15> = 1 ). following a start bit detection, 8 bits are shifted into i2crsr and the address is compared with i2cadd, and is also compared with the general call address which is fixed in hardware. if a general call address match occurs, the i2crsr is transferred to the i2crcv after the eighth clock, the rbf flag is set, and, on the falling edge of the ninth bit (ack bit), the master event interrupt flag (mi2cif) is set. when the interrupt is serviced, the source for the inter- rupt can be checked by reading the contents of the i2crcv to determine if the address was device specific, or a general call address. 14.11 i 2 c master support as a master device, six operations are supported. ? assert a start condition on sda and scl. ? assert a restart condition on sda and scl. ? write to the i2ctrn register initiating transmission of data/address. ? generate a stop condition on sda and scl. ? configure the i 2 c port to receive data. ? generate an ack condition at the end of a received byte of data. 14.12 i 2 c master operation the master device generates all of the serial clock pulses and the start and stop conditions. a transfer is ended with a stop condition or with a repeated start condition. since the repeated start condition is also the beginning of the next serial transfer, the i 2 c bus will not be released. in master transmitter mode, serial data is output through sda, while scl outputs the serial clock. the first byte transmitted contains the slave address of the receiving device (7 bits) and the data direction bit. in this case, the data direction bit (r_w) is logic ? 0 ?. serial data is transmitted 8 bits at a time. after each byte is transmitted, an ack bit is received. start and stop con- ditions are output to indicate the beginning and the end of a serial transfer. in master receive mode, the first byte transmitted con- tains the slave address of the transmitting device (7 bits) and the data direction bit. in this case, the data direction bit (r_w) is logic 1 . thus, the first byte trans- mitted is a 7-bit slave address, followed by a ? 1 ? to indi- cate receive bit. serial data is received via sda, while scl outputs the serial clock. serial data is received 8 bits at a time. after each byte is received, an ack bit is transmitted. start and stop conditions indicate the beginning and end of transmission. 14.12.1 i 2 c master transmission transmission of a data byte, a 7-bit address, or the sec- ond half of a 10-bit address is accomplished by simply writing a value to i2ctrn register. the user should only write to i2ctrn when the module is in a wait state. this action will set the buffer full flag (tbf) and allow the baud rate generator to begin counting and start the next transmission. each bit of address/data will be shifted out onto the sda pin after the falling edge of scl is asserted. the transmit status flag, trstat (i2cstat<14>), indicates that a master transmit is in progress. 14.12.2 i 2 c master reception master mode reception is enabled by programming the receive enable (rcen) bit (i2ccon<11>). the i 2 c module must be idle before the rcen bit is set, other- wise the rcen bit will be disregarded. the baud rate generator begins counting, and, on each rollover, the state of the scl pin toggles, and data is shifted in to the i2crsr on the rising edge of each clock.
dspic30f1010/202x ds70178a-page 154 advance information ? 2006 microchip technology inc. 14.12.3 baud rate generator in i 2 c master mode, the reload value for the brg is located in the i2cbrg register. when the brg is loaded with this value, the brg counts down to ? 0 ? and stops until another reload has taken place. if clock arbitration is taking place, for instance, the brg is reloaded when the scl pin is sampled high. as per the i 2 c standard, fsck may be 100 khz or 400 khz. however, the user can specify any baud rate up to 1 mhz. i2cbrg values of ? 0 ? or ? 1 ? are illegal. equation 14-1: i2cbrg value 14.12.4 clock arbitration clock arbitration occurs when the master deasserts the scl pin (scl allowed to float high) during any receive, transmit or restart/stop condition. when the scl pin is allowed to float high, the baud rate generator is suspended from counting until the scl pin is actually sampled high. when the scl pin is sampled high, the baud rate generator is reloaded with the contents of i2cbrg and begins counting. this ensures that the scl high time will always be at least one brg rollover count in the event that the clock is held low by an external device. 14.12.5 multi-master communication, bus collision and bus arbitration multi-master operation support is achieved by bus arbitration. when the master outputs address/data bits onto the sda pin, arbitration takes place when the master outputs a ? 1 ? on sda, by letting sda float high while another master asserts a ? 0 ?. when the scl pin floats high, data should be stable. if the expected data on sda is a ? 1 ? and the data sampled on the sda pin = 0 , then a bus collision has taken place. the master will set the mi2cif pulse and reset the master portion of the i 2 c port to its idle state. if a transmit was in progress when the bus collision occurred, the transmission is halted, the tbf flag is cleared, the sda and scl lines are deasserted, and a value can now be written to i2ctrn. when the user services the i 2 c master event interrupt service routine, if the i 2 c bus is free (i.e., the p bit is set) the user can resume communication by asserting a start condition. if a start, restart, stop or acknowledge condition was in progress when the bus collision occurred, the condi- tion is aborted, the sda and scl lines are deasserted, and the respective control bits in the i2ccon register are cleared to ? 0 ?. when the user services the bus col- lision interrupt service routine, and if the i 2 c bus is free, the user can resume communication by asserting a start condition. the master will continue to monitor the sda and scl pins and, if a stop condition occurs, the mi2cif bit will be set. a write to the i2ctrn will start the transmission of data at the first data bit, regardless of where the transmitter left off when bus collision occurred. in a multi-master environment, the interrupt generation on the detection of start and stop conditions allows the determination of when the bus is free. control of the i 2 c bus can be taken when the p bit is set in the i2cstat register, or the bus is idle and the s and p bits are cleared. 14.13 i 2 c module operation during cpu sleep and idle modes 14.13.1 i 2 c operation during cpu sleep mode when the device enters sleep mode, all clock sources to the module are shutdown and stay at logic ? 0 ?. if sleep occurs in the middle of a transmission, and the state machine is partially into a transmission as the clocks stop, then the transmission is aborted. similarly, if sleep occurs in the middle of a reception, then the reception is aborted. 14.13.2 i 2 c operation during cpu idle mode for the i 2 c, the i2csidl bit selects if the module will stop on idle or continue on idle. if i2csidl = 0 , the module will continue operation on assertion of the idle mode. if i2csidl = 1 , the module will stop on idle. i 2 cbrg fcy fscl ---------- - fcy 1 111 111 ,, -------------------------- - ? ?? ?? 1 ? =
? 2006 microchip technology inc. advance information ds70178a-page 155 dspic30f1010/202x table 14-1: i 2 c? register map note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields. sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state i2crcv 0200 ? ? ? ? ? ? ? ? receive register 0000 0000 0000 0000 i2ctrn 0202 ? ? ? ? ? ? ? ? transmit register 0000 0000 1111 1111 i2cbrg 0204 ? ? ? ? ? ? ? baud rate generator 0000 0000 0000 0000 i2ccon 0206 i2cen ? i2csidl sclrel ipmien ? disslw smen gcen stren ackdt acken rcen pen rsen sen 0001 0000 0000 0000 i2cstat 0208 ackstat trstat ? ? ? ? gcstat add10 iwcol i2cov d_a p s r_w rbf tbf 0000 0000 0000 0000 i2cadd 020a ? ? ? ? ? ? address register 0000 0000 0000 0000
dspic30f1010/202x ds70178a-page 156 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 157 dspic30f1010/202x 15.0 universal asynchronous receiver transmitter (uart) module the universal asynchronous receiver transmitter (uart) module is one of the serial i/o modules available in the dspic30f1010/202x device family. the uart is a full-duplex asynchronous system that can communicate with peripheral devices, such as personal computers, lin, rs-232 and rs-485 inter- faces. the module also includes an irda encoder and decoder . the primary features of the uart module are: ? full-duplex 8 or 9-bit data transmission through the u1tx and u1rx pins ? even, odd or no parity options (for 8-bit data) ? one or two stop bits ? fully integrated baud rate generator with 16-bit prescaler ? baud rates ranging from 1 mbps to 15 bps at 16 mips ? 4-deep first-in-first-out (fifo) transmit data buffer ? 4-deep fifo receive data buffer ? parity, framing and buffer overrun error detection ? support for 9-bit mode with address detect (9th bit = 1 ) ? transmit and receive interrupts ? loopback mode for diagnostic support ? support for sync and break characters ? supports automatic baud rate detection ? irda encoder and decoder logic ? 16x baud clock output for irda support a simplified block diagram of the uart is shown in figure 15-1. the uart module consists of these key important hardware elements: ? baud rate generator ? asynchronous transmitter ? asynchronous receiver figure 15-1: uart simplified block diagram note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). u1rx irda ? uart1 receiver uart1 transmitter u1tx baud rate generator
dspic30f1010/202x ds70178a-page 158 advance information ? 2006 microchip technology inc. 15.1 uart baud rate generator (brg) the uart module includes a dedicated 16-bit baud rate generator. the u1brg register controls the period of a free-running 16-bit timer. equation 15-1 shows the formula for computation of the baud rate with brgh = 0 . equation 15-1: uart baud rate with brgh = 0 (1,2) example 15-1 shows the calculation of the baud rate error for the following conditions: ?f cy = 4 mhz ? desired baud rate = 9600 the maximum baud rate (brgh = 0 ) possible is f cy /16 (for u1brg = 0 ), and the minimum baud rate possible is f cy /(16 * 65536). equation 15-2 shows the formula for computation of the baud rate with brgh = 1 . equation 15-2: uart baud rate with brgh = 1 (1,2) the maximum baud rate (brgh = 1 ) possible is f cy /4 (for u1brg = 0 ) and the minimum baud rate possible is f cy /(4 * 65536). writing a new value to the u1brg register causes the brg timer to be reset (cleared). this ensures the brg does not wait for a timer overflow before generating the new baud rate. example 15-1: baud rate erro r calculation (brgh = 0 ) (1) note 1: f cy denotes the instruction cycle clock frequency (f osc /2 ). 2: based on t cy = 2/f osc , pll are disabled. baud rate = f cy 16 ? (u1brg + 1) f cy 16 ? baud rate u1brg = ? 1 baud rate = f cy 4 ? (u1brg + 1) f cy 4 ? baud rate u1brg = ? 1 note 1: f cy denotes the instruction cycle clock frequency . 2: based on t cy = 2/f osc , pll are disabled. desired baud rate = f cy /(16 (u1brg + 1)) solving for u1brg value: u1brg = ((f cy /desired baud rate)/16) ? 1 u1brg = ((4000000/9600)/16) ? 1 u1brg = 25 calculated baud rate = 4000000/(16 (25 + 1)) = 9615 error = (calculated baud rate ? desired baud rate) desired baud rate = (9615 ? 9600)/9600 = 0.16% note 1: based on t cy = 2/f osc , pll are disabled.
? 2006 microchip technology inc. advance information ds70178a-page 159 dspic30f1010/202x 15.2 transmitting in 8-bit data mode 1. set up the uart: a) write appropriate values for data, parity and stop bits. b) write appropriate baud rate value to the u1brg register. c) set up transmit and receive interrupt enable and priority bits. 2. enable the uart. 3. set the utxen bit (causes a transmit interrupt). 4. write data byte to lower byte of txxreg word. the value will be immediately transferred to the transmit shift register (tsr), and the serial bit stream will start shifting out with next rising edge of the baud clock. 5. alternately, the data byte may be transferred while utxen = 0 , and then the user may set utxen. this will cause the serial bit stream to begin immediately because the baud clock will start from a cleared state. 6. a transmit interrupt will be generated as per interrupt control bit, utxiselx. 15.3 transmitting in 9-bit data mode 1. set up the uart (as described in section 15.2 ?transmitting in 8-bit data mode? ). 2. enable the uart. 3. set the utxen bit (causes a transmit interrupt). 4. write txxreg as a 16-bit value only. 5. a word write to txxreg triggers the transfer of the 9-bit data to the tsr. serial bit stream will start shifting out with the first rising edge of the baud clock. 6. a transmit interrupt will be generated as per the setting of control bit, utxiselx. 15.4 break and sync transmit sequence the following sequence will send a message frame header made up of a break, followed by an auto-baud sync byte. 1. configure the uart for the desired mode. 2. set utxen and utxbrk ? sets up the break character, 3. load the txxreg with a dummy character to initiate transmission (value is ignored). 4. write ?55h? to txxreg ? loads sync character into the transmit fifo. 5. after the break has been sent, the utxbrk bit is reset by hardware. the sync character now transmits. 15.5 receiving in 8-bit or 9-bit data mode 1. set up the uart (as described in section 15.2 ?transmitting in 8-bit data mode? ). 2. enable the uart. 3. a receive interrupt will be generated when one or more data characters have been received as per interrupt control bit, urxiselx. 4. read the oerr bit to determine if an overrun error has occurred. the oerr bit must be reset in software. 5. read rxxreg. the act of reading the rxxreg character will move the next character to the top of the receive fifo, including a new set of perr and ferr values. 15.6 built-in irda encoder and decoder the uart has full implementation of the irda encoder and decoder as part of the uart module. the built-in irda encoder and decoder functionality is enabled using the iren bit u1mode<12>. when enabled (iren = 1 ), the receive pin (u1rx) acts as the input from the infrared receiver. the transmit pin (u1tx) acts as the output to the infrared transmitter. 15.7 alternate uart i/o pins an alternate set of i/o pins, u1atx and u1arx can be used for communications. the alternate uart pins are useful when the primary uart pins are shared by other peripherals. the alternate i/o pins are enabled by set- ting the altio bit in the uxmode register. if altio = 1 , the u1atx and u1arx pins are used by the uart module, instead of the u1tx and u1rx pins. if altio = 0 , the u1tx and u1rx pins are used by the uart module.
dspic30f1010/202x ds70178a-page 160 advance information ? 2006 microchip technology inc. register 15-1: u1mode: uart1 mode register r/w-0 u-0 r/w-0 r/w-0 u-0 r/w-0 u-0 u-0 uarten ? usidl iren ?altio ? ? bit 15 bit 8 r/w-0 hc r/w-0 r/w-0 hc r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wake lpback abaud rxinv brgh pdsel1 pdsel0 stsel bit 7 bit 0 legend: u = unimplemented bit, read as ?0? r = readable bit w = writable bit hc = hardware cleared hs = hardware select -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 uarten: uart1 enable bit 1 = uart1 is enabled; all uart1 pins are controlled by uart1 as defined by uen<1:0> 0 = uart1 is disabled; all uart1 pins are cont rolled by port latches; uart1 power consumption minimal bit 14 unimplemented: read as ? 0 ? bit 13 usidl: stop in idle mode bit 1 = discontinue module operation when device enters idle mode 0 = continue module operation in idle mode bit 12 iren: irda encoder and decoder enable bit 1 = irda encoder and decoder enabled 0 = irda encoder and decoder disabled note: this feature is only available for the 16x brg mode (brgh = 0 ). bit 11 unimplemented: read as ? 0 ? bit 10 altio: uart alternate i/o selection bit 1 = uart communicates using u1atx and u1arx i/o pins 0 = uart communicates using u1tx and u1rx i/o pins. bit 9-8 unimplemented: read as ? 0 ? bit 7 wake: wake-up on start bit detect during sleep mode enable bit 1 = uart1 will continue to sample the u1rx pin; interrupt generated on falling edge, bit cleared in hardware on following rising edge 0 = no wake-up enabled bit 6 lpback: uart1 loopback mode select bit 1 = enable loopback mode 0 = loopback mode is disabled bit 5 abaud: auto-baud enable bit 1 = enable baud rate measurement on the next character ? requires reception of a sync field (55h); cleared in hardware upon completion 0 = baud rate measurement disabled or completed bit 4 rxinv: receive polarity inversion bit 1 = u1rx idle state is ? 0 ? 0 = u1rx idle state is ? 1 ? bit 3 brgh: high baud rate enable bit 1 = brg generates 4 clocks per bit period (4x baud clock, high-speed mode) 0 = brg generates 16 clocks per bit period (16x baud clock, standard mode)
? 2006 microchip technology inc. advance information ds70178a-page 161 dspic30f1010/202x bit 2-1 pdsel1:pdsel0: parity and data selection bits 11 = 9-bit data, no parity 10 = 8-bit data, odd parity 01 = 8-bit data, even parity 00 = 8-bit data, no parity bit 0 stsel: stop bit selection bit 1 = two stop bits 0 = one stop bit register 15-1: u1mode: uart1 mode register
dspic30f1010/202x ds70178a-page 162 advance information ? 2006 microchip technology inc. register 15-2: u1sta: uart1 status and control register r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 utxisel1 utxinv (1) utxisel0 ? utxbrk utxen utxbf trmt bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 urxisel1 urxisel0 adden ridle perr ferr oerr urxda bit 7 bit 0 legend: u = unimplemented bit, read as ?0? r = readable bit w = writable bit hs =hardware set hc = hardware cleared -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15, 13 utxisel1:utxisel0: transmission interrupt mode selection bits 11 = reserved; do not use 10 = interrupt when a character is transferred to the transmit shift register and as a result, the transmit buffer becomes empty 01 = interrupt when the last character is shifted out of the transmit shift register; all transmit operations are completed 00 =interrupt when a character is transferred to the transmit shift register (this implies there is at least one character open in the transmit buffer) bit 14 utxinv: irda encoder transmit polarity inversion bit (1) 1 = irda encoded u1tx idle state is ? 1 ? 0 = irda encoded u1tx idle state is ? 0 ? note 1: value of bit only affects the transmit properties of the module when the irda encoder is enabled (iren = 1 ). bit 12 unimplemented: read as ? 0 ? bit 11 utxbrk: transmit break bit 1 = send sync break on next transmission ? start bit, followed by twelve ? 0 ? bits, followed by stop bit; cleared by hardware upon completion 0 = sync break transmission disabled or completed bit 10 utxen: transmit enable bit 1 = transmit enabled, u1tx pin controlled by uart1 0 = transmit disabled, any pending transmission is aborted and buffer is reset. u1tx pin controlled by port. bit 9 utxbf: transmit buffer full status bit (read-only) 1 = transmit buffer is full 0 = transmit buffer is not full, at least one more character can be written bit 8 trmt: transmit shift register empty bit (read-only) 1 = transmit shift register is empty and transmit buffer is empty (the last transmission has completed) 0 = transmit shift register is not empty, a transmission is in progress or queued bit 7-6 urxisel1:urxisel0: receive interrupt mode selection bits 11 = interrupt is set on rsr transfer, making the receive buffer full (i.e., has 4 data characters) 10 = interrupt is set on rsr transfer, making the receive buffer 3/4 full (i.e., has 3 data characters) 0x =interrupt is set when any character is received and transferred from the rsr to the receive buffer. receive buffer has one or more characters. bit 5 adden: address character detect bit (bit 8 of received data = 1 ) 1 = address detect mode enabled. if 9-bit mode is not selected, this does not take effect. 0 = address detect mode disabled
? 2006 microchip technology inc. advance information ds70178a-page 163 dspic30f1010/202x bit 4 ridle: receiver idle bit (read-only) 1 = receiver is idle 0 = receiver is active bit 3 perr: parity error status bit (read-only) 1 = parity error has been detected for the current character (character at the top of the receive fifo) 0 = parity error has not been detected bit 2 ferr: framing error status bit (read-only) 1 = framing error has been detected for the current character (character at the top of the receive fifo) 0 = framing error has not been detected bit 1 oerr: receive buffer overrun error status bit (read/clear-only) 1 = receive buffer has overflowed 0 = receive buffer has not overflowed (clearing a previously set oerr bit ( 1 0 transition) will reset the receiver buffer and the rsr to the empty state) bit 0 urxda: receive buffer data available bit (read-only) 1 = receive buffer has data, at least one more character can be read 0 = receive buffer is empty register 15-2: u1sta: uart1 status and control register
dspic30f1010/202x ds70178a-page 164 advance information ? 2006 microchip technology inc. table 15-1: uart1 register map sfr name sfr addr bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets u1mode 0220 uarten ?usidliren ?altio ? ? wake lpback abaud rxinv brgh pdsel<1:0> stsel 0000 u1sta 0222 utxisel1 utxinv utxisel0 ? utxbrk utxen utxbf trmt urxisel<1:0> adden ridle perr ferr oerr urxda 0110 u1txreg 0224 ? ? ? ? ? ? ? uart transmit register xxxx u1rxreg 0226 ? ? ? ? ? ? ? uart receive register 0000 u1brg 0228 baud rate generator prescaler 0000 legend: x = unknown value on reset, ? = unimplemented, read as ? 0 ?. reset values are shown in hexadecimal.
? 2006 microchip technology inc. advance information ds70178a-page 165 dspic30f1010/202x 16.0 10-bit 2 msps analog-to- digital converter (adc) module the dspic30f1010/202x devices provide high-speed successive approximation analog to digital conver- sions to support applications such as ac/dc and dc/dc power converters. 16.1 features ? 10-bit resolution ? uni-polar inputs ? up to 12 input channels ? 1 lsb accuracy ? single supply operation ? 2000 ksps conversion rate at 5v ? 1000 ksps conversion rate at 3.0v ? low power cmos technology 16.2 description this adc module is designed for applications that require low latency between the request for conversion and the resultant output data. typical applications include: ? ac/dc power supplies ? dc/dc converters ? power factor correction this adc works with the power supply pwm module in power control applications that require high-fre- quency control loops. this module can sample and convert two analog inputs in one microsecond. the one microsecond conversion delay reduces the ?phase lag? between measurement and control system response. up to 4 inputs may be sampled at a time, and up to 12 inputs may request conversion at a time. if multiple inputs request conversion, the adc will convert them in a sequential manner starting with the lowest order input. this adc design provides each pair of analog inputs (an1,an0), (an3,an2), ... , the ability to specify its own trigger source out of a maximum of sixteen different trigger sources. this capability allows this adc to sam- ple and convert analog inputs that are associated with pwm generators operating on independent time bases. there is no operation during sleep mode. the user applications typically require synchronization between analog data sampling and pwm output to the applica- tion circuit. the very high speed operation of this adc module allows ?data on demand?. in addition, several hardware features have been added to the peripheral interface to improve real-time performance in a typical dsp based application. 1. result alignment options 2. automated sampling 3. external conversion start control a block diagram of the adc module is shown in figure 16-1. 16.3 module functionality the 10-bit 2 msps adc is designed to support power conversion applications when used with the power supply pwm module. the 10-bit 2 msps adc samples up to n (n 12) inputs at a time and then converts two sampled inputs at a time. the quantity of sample and hold circuits is determined by a device?s requirements. the10-bit 2 msps adc produces two 10-bit conversion results in 1 microsecond. the adc module supports up to 12 analog inputs. the sampled inputs are connected, via multiplexers, to the converter. the analog reference voltage is defined as the device supply voltage (av dd / av ss ). the a/d module uses these control and status regis- ters: ? a/d control register (adcon) ? a/d status register (adstat) ? a/d base register (adbase)(1) ? a/d port configuration register (adpcfg) ? a/d convert pair control register #0 (adcpc0) ? a/d convert pair control register #1 (adcpc1) ? a/d convert pair control register #2 (adcpc2) the adcon register controls the operation of the adc module. the adstat register displays the status of the conversion processes. the adpcfg registers config- ure the port pins as analog inputs or as digital i/o. the cpc registers control the triggering of the adc conver- sions. (see register 16-1 through register 16-7 for detailed bit configurations.) note: a unique feature of the adc module is its abil- ity to sample inputs in an asynchronous manner. indi- vidual sample and hold circuits can be triggered independently of each other. note: the pll must be enabled for the adc module to function. this is achieved by using the fnosc<1:0> bits in the foscsel configuration register.
dspic30f1010/202x ds70178a-page 166 advance information ? 2006 microchip technology inc. figure 16-1: adc block diagram av ss av dd data bus interface mux / sample / sequence control format dac 12-word, 16-bit registers comparator 10-bit sar conversion logic an0 an2 an6 an1 an11 an3 an8 an10 even numbered inputs without dedicated s&h dedicated s&hs an4
? 2006 microchip technology inc. advance information ds70178a-page 167 dspic30f1010/202x register 16-1: a/d control register (adcon) r/w-0 u-0 r/w-0 u-0 u-0 r/w-0 u-0 r/w-0 adon ?adsidl ? ?gswtrg ?form bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 u-0 r/w-0 r/w-1 r/w-1 eie order seqsamp ? ? adcs<2:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 adon: a/d operating mode bit 1 = a/d converter module is operating 0 = a/d converter is off bit 14 unimplemented: read as ? 0 ? bit 13 adsidl: stop in idle mode bit 1 = discontinue module operation when device enters idle mode 0 = continue module operation in idle mode bit 12-11 unimplemented: read as ? 0 ? bit 10 gswtrg: global software trigger bit when this bit is set by the user, it will trigger conversions if selected by the trgsrc<4:0> bits in the cpcx registers. this bit must be cleared by the user prior to initiating another global trigger (i.e., this bit is not auto-clearing). bit 9 unimplemented: read as ? 0 ? bit 8 form: data output format bit 1 = fractional (d out = dddd dddd dd00 0000 ) 0 = integer (d out = 0000 00dd dddd dddd ) bit 7 eie: early interrupt enable bit 1 = interrupt is generated after first conversion is completed 0 = interrupt is generated after second conversion is completed note: this control bit can only be changed while adc is disabled (adon = 0 ). bit 6 order: conversion order bit 1 = odd numbered analog input is converted first, followed by conversion of even numbered input 0 = even numbered analog input is converted first, followed by conversion of odd numbered input note: this control bit can only be changed while adc is disabled (adon = 0 ). bit 5 seqsamp: sequential sample enable. 1 = shared s&h is sampled at the start of the second conversion if order = 0 . if order = 1 , then the shared s&h is sampled at the start of the first conversion. 0 = shared s&h is sampled at the same time the dedicated s&h is sampled if the shared s&h is not currently busy with an existing conversion process. if the shared s&h is busy at the time the dedicated s&h is sampled, then the shared s&h will sample at the start of the new conversion cycle bit 4-3 unimplemented: read as ? 0 ? bit 2-0 adcs<2:0>: a/d conversion clock select bits 111 = t q (adcs<2:0> +1) = 8 t q 001 = t q (adcs<2:0> +1) = 2 t q 000 = t q (adcs<2:0> +1) = 1 t q note: t q = period of system clock @ 30 mips = 16.6 nsec (60 mhz)
dspic30f1010/202x ds70178a-page 168 advance information ? 2006 microchip technology inc. register 16-2: a/d status register (adstat) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 ? ? ? ? ? ? ? ? bit 15 bit 8 u-0 u-0 r/c-0 h-s r/c-0 h-s r/c-0 h-s r/c-0 h-s r/c-0 h-s r/c-0 h-s ? ? p5rdy p4rdy p3rdy p2rdy p1rdy p0rdy bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por c = clear in software ?1? = bit is set h-s = set by hardware ?0? = bit is cleared x = bit is unknown bit 15-6 unimplemented: read as ? 0 ? bit 5 p5rdy: conversion data for pair #5 ready bit bit set when data is ready in buffer, cleared when a ? 0 ? is written to this bit. bit 4 p4rdy: conversion data for pair #4 ready bit bit set when data is ready in buffer, cleared when a ? 0 ? is written to this bit. bit 3 p3rdy: conversion data for pair #3 ready bit bit set when data is ready in buffer, cleared when a ? 0 ? is written to this bit. bit 2 p2rdy: conversion data for pair #2 ready bit bit set when data is ready in buffer, cleared when a ? 0 ? is written to this bit. bit 1 p1rdy: conversion data for pair #1 ready bit bit set when data is ready in buffer, cleared when a ? 0 ? is written to this bit. bit 0 p0rdy: conversion data for pair #0 ready bit bit set when data is ready in buffer, cleared when a ? 0 ? is written to this bit.
? 2006 microchip technology inc. advance information ds70178a-page 169 dspic30f1010/202x register 16-3: a/d base register (adbase) (1) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 adbase<15:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 adbase<7:1> ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-1 adc base register: this register contains the base address of the user?s adc interrupt service rou- tine jump table. this register, when read, contains the sum of the adbase register contents and the encoded value of the pxrdy status bits. the encoder logic provides the bit number of the highest priority pxrdy bits where p0rdy is the highest priority, and p5rdy is lowest priority. note: the encoding results are shifted left two bits so bits 1-0 of the result are always zero. bit 0 unimplemented: read as ? 0 ? note 1: as an alternative to using the adbase register, the adcp0-5 adc pair conversion complete interrupts (interrupts 37-42) can be used to invoke a to d conversion completion routines for individual adc input pairs. refer to section 16.9 ?individual pair interrupts? . register 16-4: a/d port conf iguration register (adpcfg) u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ? ? ? pcfg11 pcfg10 pcfg9 pcfg8 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 pcfg7 pcfg6 pcfg5 pcfg4 pcfg3 pcfg2 pcfg1 pcfg0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-12 unimplemented: read as ? 0 ? bit 11-0 pcfg<11:0>: a/d port configuration control bits 1 = port pin in digital mode, port read input enabled, a/d input multiplexor connected to av ss 0 = port pin in analog mode, port read input disabled, a/d samples pin voltage
dspic30f1010/202x ds70178a-page 170 advance information ? 2006 microchip technology inc. register 16-5: a/d convert pair control register #0 (adcpc0) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 irqen1 pend1 swtrg1 trgsrc1<5:0> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 irqen0 pend0 swtrg0 trgsrc0<5:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 irqen1: interrupt request enable 1 bit 1 = enable irq generation when requested conversion of channels an3 and an2 is completed 0 = irq is not generated bit 14 pend1: pending conversion status 1 bit 1 = conversion of channels an3 and an2 is pending. set when selected trigger is asserted 0 = conversion is complete bit 13 swtrg1: software trigger 1 bit 1 = start conversion of an3 and an2 (if selected in trgsrc bits). if other conversions are in progress, then conversion will be performed when the conversion resources are available. this bit will be reset when the pend bit is set. bit 12-8 trgsrc1<5:0>: trigger 1 source selection bits selects trigger source for conversion of analog channels an3 and an2. 00000 = no conversion enabled 00001 = individual software trigger selected 00010 = global software trigger selected 00011 = pwm special event trigger selected 00100 = pwm generator #1 trigger selected 00101 = pwm generator #2 trigger selected 00110 = pwm generator #3 trigger selected 00111 = pwm generator #4 trigger selected 01100 = timer #1 period match 01101 = timer #2 period match 01110 = pwm gen #1 current-limit adc trigger 01111 = pwm gen #2 current-limit adc trigger 10000 = pwm gen #3 current-limit adc trigger 10001 = pwm gen #4 current-limit adc trigger 10110 = pwm gen #1 fault adc trigger 10111 = pwm gen #2 fault adc trigger 11000 = pwm gen #3 fault adc trigger 11001 = pwm gen #4 fault adc trigger bit 7 irqen0: interrupt request enable 0 bit 1 = enable irq generation when requested conversion of channels an1 and an0 is completed 0 = irq is not generated bit 6 pend0: pending conversion status 0 bit 1 = conversion of channels an1 and an0 is pending. set when selected trigger is asserted. 0 = conversion is complete bit 5 swtrg0: software trigger 0 bit 1 = start conversion of an1 and an0 (if selected by trgsrc bits). if other conversions are in progress, then conversion will be performed when the conversion resources are available. this bit will be reset when the pend bit is set
? 2006 microchip technology inc. advance information ds70178a-page 171 dspic30f1010/202x bit 4-0 trgsrc0<5:0>: trigger 0 source selection bits selects trigger source for conversion of analog channels an1 and an0. 00000 = no conversion enabled 00001 = individual software trigger selected 00010 = global software trigger selected 00011 = pwm special event trigger selected 00100 = pwm generator #1 trigger selected 00101 = pwm generator #2 trigger selected 00110 = pwm generator #3 trigger selected 00111 = pwm generator #4 trigger selected 01100 = timer #1 period match 01101 = timer #2 period match 01110 = pwm gen #1 current-limit adc trigger 01111 = pwm gen #2 current-limit adc trigger 10000 = pwm gen #3 current-limit adc trigger 10001 = pwm gen #4 current-limit adc trigger 10110 = pwm gen #1 fault adc trigger 10111 = pwm gen #2 fault adc trigger 11000 = pwm gen #3 fault adc trigger 11001 = pwm gen #4 fault adc trigger register 16-5: a/d convert pair control register #0 (adcpc0) (continued)
dspic30f1010/202x ds70178a-page 172 advance information ? 2006 microchip technology inc. register 16-6: a/d convert pair control register #1 (adcpc1) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 irqen3 pend3 swtrg3 trgsrc3<5:0> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 irqen2 pend2 swtrg2 trgsrc2<5:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 irqen3: interrupt request enable 3 bit 1 = enable irq generation when requested conversion of channels an7 and an6 is completed. 0 = irq is not generated bit 14 pend3: pending conversion status 3 bit 1 = conversion of channels an7 and an6 is pending. set when selected trigger is asserted. 0 = conversion is complete bit 13 swtrg3: software trigger 3 bit 1 = start conversion of an7 and an6 (if selected by trgsrc bits). if other conversions are in progress, then conversion will be performed when the conversion resources are available. this bit will be reset when the pend bit is set. bit 12-8 trgsrc3<5:0>: trigger 3 source selection bits selects trigger source for conversion of analog channels a7 and a6. 00000 = no conversion enabled 00001 = individual software trigger selected 00010 = global software trigger selected 00011 = pwm special event trigger selected 00100 = pwm generator #1 trigger selected 00101 = pwm generator #2 trigger selected 00110 = pwm generator #3 trigger selected 00111 = pwm generator #4 trigger selected 01100 = timer #1 period match 01101 = timer #2 period match 01110 = pwm gen #1 current-limit adc trigger 01111 = pwm gen #2 current-limit adc trigger 10000 = pwm gen #3 current-limit adc trigger 10001 = pwm gen #4 current-limit adc trigger 10110 = pwm gen #1 fault adc trigger 10111 = pwm gen #2 fault adc trigger 11000 = pwm gen #3 fault adc trigger 11001 = pwm gen #4 fault adc trigger bit 7 irqen2: interrupt request enable 2 bit 1 = enable irq generation when requested conversion of channels an5 and an4 is completed 0 = irq is not generated bit 6 pend2: pending conversion status 2 bit 1 = conversion of channels an5 and an4 is pending. set when selected trigger is asserted 0 = conversion is complete bit 5 swtrg2: software trigger 2 bit 1 = start conversion of an5 and an4 (if selected by trgsrc bits). if other conversions are in progress, then conversion will be performed when the conversion resources are available. this bit will be reset when the pend bit is set
? 2006 microchip technology inc. advance information ds70178a-page 173 dspic30f1010/202x bit 3-0 trgsrc2<5:0>: trigger 2 source selection bits selects trigger source for conversion of analog channels: an5 and an4 00000 = no conversion enabled 00001 = individual software trigger selected 00010 = global software trigger selected 00011 = pwm special event trigger selected 00100 = pwm generator #1 trigger selected 00101 = pwm generator #2 trigger selected 00110 = pwm generator #3 trigger selected 00111 = pwm generator #4 trigger selected 01100 = timer #1 period match 01101 = timer #2 period match 01110 = pwm gen #1 current-limit adc trigger 01111 = pwm gen #2 current-limit adc trigger 10000 = pwm gen #3 current-limit adc trigger 10001 = pwm gen #4 current-limit adc trigger 10110 = pwm gen #1 fault adc trigger 10111 = pwm gen #2 fault adc trigger 11000 = pwm gen #3 fault adc trigger 11001 = pwm gen #4 fault adc trigger register 16-6: a/d convert pair control register #1 (adcpc1) (continued)
dspic30f1010/202x ds70178a-page 174 advance information ? 2006 microchip technology inc. register 16-7: a/d convert pair control register #2 (adcpc2) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 irqen5 pend5 swtrg5 trgsrc5<5:0> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 irqen4 pend4 swtrg4 trgsrc4<5:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown . bit 15 irqen5: interrupt request enable 5 bit 1 = enable irq generation when requested conversion of channels an11 and an10 is completed 0 = irq is not generated bit 14 pend5: pending conversion status 5 bit 1 = conversion of channels an11 and an10 is pending. set when selected trigger is asserted 0 = conversion is complete bit 13 swtrg5: software trigger 5 bit 1 = start conversion of an11 and an10 (if selected by trgsrc bits). if other conversions are in progress, then conversion will be performed when the conversion resources are available. this bit will be reset when the pend bit is set. bit 11-8 trgsrc5<5:0>: trigger source selection 5 bits selects trigger source for conversion of analog channels a11 and a10. 00000 = no conversion enabled 00001 = individual software trigger selected 00010 = global software trigger selected 00011 = pwm special event trigger selected 00100 = pwm generator #1 trigger selected 00101 = pwm generator #2 trigger selected 00110 = pwm generator #3 trigger selected 00111 = pwm generator #4 trigger selected 01100 = timer #1 period match 01101 = timer #2 period match 01110 = pwm gen #1 current-limit adc trigger 01111 = pwm gen #2 current-limit adc trigger 10000 = pwm gen #3 current-limit adc trigger 10001 = pwm gen #4 current-limit adc trigger 10110 = pwm gen #1 fault adc trigger 10111 = pwm gen #2 fault adc trigger 11000 = pwm gen #3 fault adc trigger 11001 = pwm gen #4 fault adc trigger bit 7 irqen4: interrupt request enable 4 bit 1 = enable irq generation when requested conversion of channels an9 and an8 is completed 0 = irq is not generated bit 6 pend4: pending conversion status 4 bit 1 = conversion of channels an9 and an8 is pending. set when selected trigger is asserted. 0 = conversion is complete bit 5 swtrg4: software trigger 4 bit 1 = start conversion of an9 and an8 (if selected by trgsrc bits). if other conversions are in progress, then conversion will be performed when the conversion resources are available. this bit will be reset when the pend bit is set.
? 2006 microchip technology inc. advance information ds70178a-page 175 dspic30f1010/202x bit 4-0 trgsrc4<5:0>: trigger source selection 4 bits selects trigger source for conversion of analog channels: an9 and an8 00000 = no conversion enabled 00001 = individual software trigger selected 00010 = global software trigger selected 00011 = pwm special event trigger selected 00100 = pwm generator #1 trigger selected 00101 = pwm generator #2 trigger selected 00110 = pwm generator #3 trigger selected 00111 = pwm generator #4 trigger selected 01100 = timer #1 period match 01101 = timer #2 period match 01110 = pwm gen #1 current-limit adc trigger 01111 = pwm gen #2 current-limit adc trigger 10000 = pwm gen #3 current-limit adc trigger 10001 = pwm gen #4 current-limit adc trigger 10110 = pwm gen #1 fault adc trigger 10111 = pwm gen #2 fault adc trigger 11000 = pwm gen #3 fault adc trigger 11001 = pwm gen #4 fault adc trigger register 16-7: a/d convert pair control register #2 (adcpc2) (continued)
dspic30f1010/202x ds70178a-page 176 advance information ? 2006 microchip technology inc. 16.4 adc result buffer the adc module contains up to 12 data output regis- ters to store the a/d results called adbuf<11:0>. the registers are 10 bits wide, but are read into different format, 16-bit words. the buffers are read-only. each analog input has a corresponding data output register. this module does not include a circular data buffer or fifo. because the conversion results may be produced in any order, such schemes will not work since there would be no means to determine which data is in a specific location. the sar write to the buffers is synchronous to the adc clock. reads from the buffers will always have valid data assuming that the data-ready interrupt has been processed. if a buffer location has not been read by the software and the sar needs to overwrite that location, the previous data is lost. reads from the result buffer pass through the data for- matter. the 10 bits of the result data are formatted into a 16-bit word. 16.5 application information the adc module implements a concept based on ?conversion pairs?. in power conversion applications, there is a need to measure voltages and currents for each pwm control loop. the adc module enables the sample and conversion process of each conversion pair to be precisely timed relative to the pwm signals. in a user?s application circuit, the pwm signal enables a transistor, which allows an inductor to charge up with current to a desired value. the longer a pwm signal is on, the longer the inductor is charging, and therefore the inductor current is at its maximum at the end of the pwm signal. often, this is the point where the user wants to take the current and voltage measurements. figure 16-2 shows a typical power conversion applica- tion (a boost converter) where the current sensing of the inductor is done by monitoring the voltage across a resistor in series with the power transistor that ?charges? the inductor. the significant feature of this figure is that if the sampling of the resistor voltage occurs slightly later than the desired sample point, the data read will be zero. this is not acceptable in most applications. the adc module always samples the analog voltages at the appointed time regardless of whether the adc converter is busy or not. the power supply pwm module supports 2-4 indepen- dent pwm channels as well as 2-4 trigger signals (one per pwm generator). the user can configure these channels to initiate an adc conversion of a selected input pair at the proper time in the pwm cycle. the power supply pwm module also provides an addi- tional trigger signal (special event trigger), which can be programmed to occur at a specified time during the primary time base count cycle. figure 16-2: application example: importance of precise sampling x pwm i l i r x x late sample yields zero data desired sample point critical edge +v in i l l pwm v isense v out c out + i r r measuring peak inductor cu rrent is very important example boost converter
? 2006 microchip technology inc. advance information ds70178a-page 177 dspic30f1010/202x 16.6 reverse conversion order the order control bit in the adcon register, when set, reverses the order of the input pair conversion pro- cess. normally (order = 0 ), the even numbered input of an input pair is converted first, and then the odd numbered input is converted. if order = 1 , the odd numbered input pin of an input pair is converted first, followed by the even numbered pin. this feature is useful when using voltage control modes and using the early interrupt capability (eie = 1 ). these features enable the user to minimize the time period from actual acquisition of the feedback (adc) data to the update of the control output (pwm). this time from input to output of the control system determines the overall stability of the control system. 16.7 simultaneous & sequential sampling in a pair the inputs that have dedicated sample and hold (s&h) circuits are sampled when their specified trigger events occur. the inputs that share the common sam- ple and hold circuit are sampled in the following manner: 1. if the seqsamp bit = 0 , and the common (shared) sample and hold circuit is not busy, then the shared s&h will sample their specified input at the same time as the dedicated s&h. this action provides ?simultaneous? sample and hold functionality. 2. if the seqsamp bit = 0 , and the shared s&h is currently busy with a conversion in progress, then the shared s&h will sample as soon as possible (at the start of the new conversion process for the pair). 3. if the seqsamp bit = 1 , then the shared s&h will sample at the start of the conversion process for that input. for example: if the order bit = 0 the shared s&h will sample at the start of the conversion of the second input. if order = 1 , then the shared s&h will sample at the start of the conversion for the first input. the seqsamp bit is useful for some applica- tions that want to minimize the time from a sample event to the conversion of the sample. when seqsamp = 0 , the logic attempts to take the samples for both inputs of a pair at the same time if the resources are available. the user can often ensure that the adc will not be busy with a prior conversion by controlling the timing of the trigger signals that initiate the conversion processes. 16.8 group interrupt generation the adc module provides a common or ?group? inter- rupt request that is the or of all of the enabled interrupt sources within the module. each cpc register has two irqenx bits, one for each analog input pair. if the irqen bit is set, an interrupt request is made to the interrupt controller when the requested conversion is completed. when an interrupt is generated, an asso- ciated pxrdy bit in the adstat register is set. the pxrdy bit is cleared by the user. the user?s software can examine the adstat register?s pxrdy bits to determine if additional requested conversions have been completed. the group interrupt is useful for applications that use a common software routine to process adc interrupts for multiple analog input pairs. this method is more traditional in concept. note: the user must clear the ifs bit associated with the adc in the interrupt controller before the pxrdy bit is cleared. failure to do so may cause interrupts to be lost. the reason is that the adc will possibly have another interrupt pending. if the user clears the pxrdy bit first, the adc may generate another interrupt request, but if the user then clears the ifs bit, the interrupt request will be erased.
dspic30f1010/202x ds70178a-page 178 advance information ? 2006 microchip technology inc. 16.9 individual pair interrupts the adc module also provides individual interrupts outputs for each analog input pair. these interrupts are always enabled within the module. the pair interrupts can be individually enabled or disabled via the associated interrupt enable bits in the iec registers. using the group interrupts may require the interrupt service routine to determine which interrupt source generated the interrupt. for applications that use sep- arate software tasks to process adc data, a common interrupt vector can cause performance bottlenecks. the use of the individual pair interrupts can save many clock cycles as compared to using the group interrupt to process multiple interrupt sources. the individual pair interrupts support the construction of application software that is responsive and organized on a task basis. regardless of whether an individual pair interrupt or the global interrupt are used to respond to an interrupt request from an adc conversion, the pxrdy bits in the adstat register function in the same manner. the use of the individual pair interrupts also enables the user to change the interrupt priority of individual adc channels (pairs) as compared to the fixed priority structure of the group interrupt. note: the use of individual interrupts does not affect the priority structure of the adc with respect to the order of input pair conversion. the use of individual interrupts can reduce the problem of accidently ?losing? a pending interrupt while process- ing and clearing a current interrupt 16.10 early interrupt generation the eie control bit in the adcon register enables the generation of the interrupts after completion of the first conversion instead of waiting for the completion of both inputs of an input pair. even though the second input will still be in the conversion process, the software can be written to perform some of the computations using the first data value while the second conversion is completed. the user software can be written to account for the 500 nsec conversion period of the second input before using the second data, or the user can poll the pend bit in the cpcx register. the pend bit remains set until both conversions of a pair have been completed. the pxrdy bit for the associated interrupt is set in the adstat register at the completion of the first conversion, and remains set until it is cleared by the user. 16.11 conflict resolution if more than one conversion pair request is active at the same time, the adc control logic processes the requests in a top-down manner, starting at analog pair #0 (an1/an0) and ending at analog pair #5 (an11/ an10). this is not a ?round-robin? process. 16.12 deliberate conflicts if the user specifies the same conversion trigger source for multiple ?conversion pairs?, then the adc module functions like other dspic30f adc modules; i.e., it pro- cesses the requested conversions sequentially (in pairs) until the sequence has been completed. 16.13 adc clock selection the adcs<2:0> bits in the adcon register specify the clock divisor value for the adc clock generation logic. the input to the adc clock divisor is the system clock (240 mhz @ 30 mips) when the pll is operating. this high-frequency clock provides the needed timing reso- lution to generate a 24 mhz adc clock signal required to process two adc conversions in 1 microsecond. note: the adc module will not repeatedly loop once triggered. each sequence of conversions requires a trigger or multiple triggers.
? 2006 microchip technology inc. advance information ds70178a-page 179 dspic30f1010/202x 16.14 adc base register it is expected that the user application may have the adc module generate 500,000 interrupts per second. to speed the evaluation of the pxrdy bits in the adstat register, the adc module features the read/ write register: adbase. when read, the adbase reg- ister will provide a sum of the contents of the adbase register plus an encoding of the pxrdy bits set in the adstat register. the least significant bit of the adbase register is forced to zero. this ensures that all (adbase + pxrdy) results will be on instruction boundaries. the pxrdy bits are binary priority encoded with p0rdy being the highest priority, and p5rdy being the lowest priority. the encoded priority result is then shifted left two bit positions and added to the contents of the adbase register. this means the priority encoding yields addresses that are on two instruction word boundaries. the user will typically load the adbase register with the base address of a ?jump? table that contains either the addresses of the appropriate isrs or branches to the appropriate isr. the encoded pxrdy values are set up to reserve two instruction words per entry in the jump table. it is expected that the user software will use one instruction word to load an identifier into a w register, and the other instruction will be a branch to the appropriate isr. 16.15 changing a/d clock in general, the a/d cannot accept changes to the adc clock divisor while adon = 1 . if the user makes a/d clock changes while adon = 1 , the results will be indeterminate. 16.16 sample and conversion the adc module always assigns two adc clock peri- ods for the sampling process. when operating at the maximum conversion rate of 2 msps per channel, the sampling period is: 2 x 41.6 nsec = 83.3 nsec. each adc pair specified in the cpcx registers initiates a sample operation when the selected trigger event occurs. the conversion of the sampled analog data occurs as resources become available. if a new trigger event occurs for a specific channel before a previous sample and convert request for that channel has been processed, the newer request is ignored. it is the user?s responsibility not to exceed the conversion rate capability for the module. the actual conversion process requires 10 additional adc clocks. the conversion is processed serially, bit 9 first, then bit 8, down to bit 0. the result is stored when the conversion is completed. 16.17 a/d sample and convert timing the sample and hold circuits assigned to the input pins have their own timing logic that is triggered when an external sample and convert request (from pwm or tmr) is made. the sample and hold circuits have a fixed two clock data sample period. when the sample has been acquired, then the adc control logic is notified of a pending request, then the conversion is performed as the conversion resources become available. the adc module always converts pairs of analog input channels, so a typical conversion process requires 24 clock cycles.
dspic30f1010/202x ds70178a-page 180 advance information ? 2006 microchip technology inc. figure 16-3: detailed conversion sequence timings, seqsamp = 0 , not busy 10th 9th 8th 7th 6th 5th 4th 3rd 2nd 1st t ad adc_clk sample_even convert_en capture_first_data 10th 9th 8th 7th 6th 5th 4th 3rd 2nd 1st 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 0 1 2 0 1 2 3 connect_second connect_first state counter capture_second_data sample_odd
? 2006 microchip technology inc. advance information ds70178a-page 181 dspic30f1010/202x figure 16-4: detailed conversion sequence timings, seqsamp = 1 10th 9th 8th 7th 6th 5th 4th 3rd 2nd 1st t ad adc_clk sample_even convert_en capture_first_data 10th 9th 8th 7th 6th 5th 4th 3rd 2nd 1st 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 0 1 2 3 sample_odd (1) connect_second connectx_en state counter capture_second_data connect_common sample_odd (2) dependent on s&h availability note 1: for all analog input pairs that do not have dedicated sample and hold circuits, the common sample and hold circuit samples the input at the start of the first and second conversions. therefore, the samples are sequential, not simultaneous. 2: for all analog input pairs that have dedicated sample and hold circuits, the common sample and hold circuit samples the input at the start of the first conversion so that both samples (odd and even) are near simultaneous.
dspic30f1010/202x ds70178a-page 182 advance information ? 2006 microchip technology inc. 16.18 module power-down modes the module has two internal power modes. when the adon bit is ? 1 ?, the module is in active mode and is fully powered and functional. when adon is ? 0 ?, the module is in off mode. the state machine for the module is reset, as are all of the pending conversion requests. to return to the active mode from off mode, the user must wait for the bias generators to stabilize. the stabilization time is specified in the electrical specs. 16.19 effects of a reset a device reset forces all registers to their reset state. this forces the a/d module to be turned off, and any conversion and sampling sequence is aborted. the value that is in the adbufx register is not modified. the adbufx registers contain unknown data after a power-on reset. 16.20 configuring analog port pins the use of the adpcfg and tris registers control the operation of the a/d port pins. the port pins that are desired as analog inputs should have their corresponding tris bit set (input). if the tris bit is cleared (output), the digital output level (v oh or v ol ) will be converted. port pins that are desired as analog inputs must have the corresponding adpcfg bit clear. this will config- ure the port to disable the digital input buffer. analog levels on pins where adpcfg = 1 , may cause the digital input buffer to consume excessive current. if a pin is not configured as an analog input adpcfg = 1 , the analog input is forced to avss and conversions of that input do not yield meaningful results. when reading the port register, all pins configured as analog input adpcfg = 0 , will read ? 0 ?. the a/d operation is independent of the state of the input selection bits and the tris bits. some devices may have analog inputs multiplexed with a/d voltage reference inputs v ref - and v ref +. this does not affect the functionality of these pins. the user may still specify those pins as analog inputs and convert them, the results will either be 0x000 or 0xfff. 16.21 output formats the a/d converts 10 bits. the data buffer ram is 16 bits wide. the adc data can be read in one of two dif- ferent formats, as shown in figure 16-5. the form bit selects the format. each of the output formats translates to a 16-bit result on the data bus. figure 16-5: a/d output data format ram contents: d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 read to bus: fractional d09d08d07d06d05d04d03d02d01d0000000 0 integer 0 0 0 0 0 0 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00
? 2006 microchip technology inc. advance information ds70178a-page 183 dspic30f1010/202x table 16-8: adc register map file name adr bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 b it 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets adcon 0300 adon ?adsidl ? ?gswtrg ? form eie order seqsamp ? ? adcs<2:0> 0009 adpcfg1 0302 ? ? ? ? pcfg11 pcfg10 pcfg9 pcfg8 pcfg7 pcfg6 pcfg5 pcfg4 pcfg3 pcfg2 pcfg1 pcfg0 0000 reserved 0304 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0000 adstat 0306 ? ? ? ? ? ? ? ? ? ? p5rdy p4rdy p3rdy p2rdy p1rdy p0rdy 0000 adbase 0308 adbase<15:1> ? 0000 adcpc0 030a irqen1 pend1 swtrg1 trgsrc1<5:0> irqen0 pend0 swtrg0 trgsrc0<5:0> 0000 adcpc1 030c irqen3 pend3 swtrg3 trgsrc3<5:0 > irqen2 pend2 swtrg2 trgsrc2<5:0> 0000 adcpc2 030e irqen5 pend5 swtrg5 trgsrc5<5:0> irqen4 pend4 swtrg4 trgsrc4<5:0> 0000 reserved 0310 ? 031e ?- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0000 adcbuf0 0320 ? ? ? ? ? ? adc data buffer 0 xxxx adcbuf1 0322 ? ? ? ? ? ? adc data buffer 1 xxxx adcbuf2 0324 ? ? ? ? ? ? adc data buffer 2 xxxx adcbuf3 0326 ? ? ? ? ? ? adc data buffer 3 xxxx adcbuf4 0328 ? ? ? ? ? ? adc data buffer 4 xxxx adcbuf5 032a ? ? ? ? ? ? adc data buffer 5 xxxx adcbuf6 032c ? ? ? ? ? ? adc data buffer 6 xxxx adcbuf7 032e ? ? ? ? ? ? adc data buffer 7 xxxx adcbuf8 0330 ? ? ? ? ? ? adc data buffer 8 xxxx adcbuf9 0332 ? ? ? ? ? ? adc data buffer 9 xxxx adcbuf10 0334 ? ? ? ? ? ? adc data buffer 10 xxxx adcbuf11 0336 ? ? ? ? ? ? adc data buffer 11 xxxx reserved 0338 ? 037e ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0000
dspic30f1010/202x ds70178a-page 184 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 185 dspic30f1010/202x 17.0 smps comparator module the dspic30f smps comparator module monitors current and/or voltage transients that may be too fast for the cpu and adc to capture. 17.1 features overview ? 16 comparator inputs ? 10-bit dac provides reference ? programmable output polarity ? interrupt generation capability ? selectable input sources ? dac has three ranges of operation -av dd / 2 - internal reference 1.2v 1% - external reference < (av dd ? 1.6v) ? adc sample and convert trigger capability ? can be disabled to reduce power consumption ? functional support for pwm module: - pwm duty cycle control - pwm period control - pwm fault detect figure 17-1: comparator module block diagram 17.2 module applications this module provides a means for the smps dspic dsc devices to monitor voltage and currents in a power conversion application. the ability to detect transient conditions and stimulate the dspic dsc pro- cessor and/or peripherals without requiring the proces- sor and adc to constantly monitor voltages or currents frees the dspic dsc to perform other tasks. the comparator module has a high-speed comparator and an associated 10-bit dac that provides a pro- grammable reference voltage to one input of the com- parator. the polarity of the comparator output is user programmable. the output of the module can be used in the following modes: ? generate an interrupt ? trigger an adc sample and convert process ? truncate the pwm signal (current limit) ? truncate the pwm period (current minimum) ? disable the pwm outputs (fault-latch) the output of the comparator module may be used in multiple modes at the same time, such as: (1) gener- ate an interrupt, (2) have the adc take a sample and convert it and (3) truncate the pwm output in response to a voltage being detected beyond its expected value. the comparator module can also be used to wake-up the system from sleep or idle mode when the analog input voltage exceeds the programmed threshold voltage. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). cmp x a* cmp x c* dac cmppol 0 1 av dd /2 v ref a vss m u x cmref cmp x * range insel<1:0> 10 trigger to pwm interrupt request cmp x b* cmp x d* glitch filter pulse generator status extref m u x * x=1, 2, 3 & 4
dspic30f1010/202x ds70178a-page 186 advance information ? 2006 microchip technology inc. 17.3 module description the comparator module uses a 20 nsec comparator. the comparator offset is 5 mv typical. the negative input of the comparator is always connected to the dac circuit. the positive input of the comparator is connected to an analog multiplexer that selects the desired source pin. 17.4 dac the range of the dac is controlled via an analog mul- tiplexer that selects either av dd / 2, internal 1.2v 1% reference, or an external reference source extref. the full range of the dac (av dd / 2) will typically be used when the chosen input source pin is shared with the adc. the reduced range option (v ref ) will likely be used when monitoring current levels via a clx pin using a current sense resistor. usually, the measured voltages in such applications are small (<1.25v), therefore the option of using a reduced reference range for the comparator extends the available dac resolution in these applications. the use of an external reference enables the user to connect to a reference that better suits their application. 17.5 interaction with i/o buffers if the comparator module is enabled and a pin has been selected as the source for the comparator, then the chosen i/o pad must disable the digital input buffer associated with the pad to prevent excessive currents in the digital buffer due to analog input voltages. 17.6 digital logic the cmpconx register (see register 17-1) provides the control logic that configures the comparator mod- ule. the digital logic provides a glitch filter for the com- parator output to mask transient signals less than two t cy (66 nsec) in duration. in sleep or idle mode, the glitch filter is bypassed to enable an asynchronous path from the comparator to the interrupt controller. this asynchronous path can be used to wake-up the processor from sleep or idle mode. the comparator can be disabled while in idle mode if the cmpsidl bit is set. if a device has multiple com- parators, if any cmpsidl bit is set, then the entire group of comparators will be disabled while in idle mode. this behavior reduces complexity in the design of the clock control logic for this module. the digital logic also provides a one t cy width pulse generator for triggering the adc and generating interrupt requests. the cmpdacx (see register 17-2) register provides the digital input value to the reference dac. if the module is disabled, the dac and comparator are disabled to reduce power consumption. 17.7 comparator input range the comparator has a limitation for the input common mode range (cmr) of about 3.5 volts (av dd ? 1.5 volts). this means that both inputs should not exceed this value or the comparator?s output will become inde- terminent. as long as one of the inputs is within the common mode range, the comparator output will be correct. an input excursion into the cmr region will not corrupt the comparator output, but the comparator input is saturated. 17.8 dac output range the dac has a limitation for the maximum reference voltage input of (av dd ? 1.6) volts. an external refer- ence voltage input should not exceed this value or the reference dac output will become indeterminate. 17.9 comparator registers the comparator module is controlled by the following registers: ? comparator control registerx (cmpconx) ? comparator dac control registerx (cmpdacx)
? 2006 microchip technology inc. advance information ds70178a-page 187 dspic30f1010/202x register 17-1: comparator control register x (cmpconx) r/w-0 u-0 r/w-0 u-0 u-0 u-0 u-0 u-0 cmpon ? cmpsidl ? ? ? ? ? bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 r/w-0 u-0 r/w-0 r/w-0 insel<1:0> extref ? cmpstat ? cmppol range bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 cmpon: a/d operating mode bit 1 = comparator module is enabled 0 = comparator module is disabled (reduces power consumption) bit 14 unimplemented: read as ? 0 ? bit 13 cmpsidl: stop in idle mode bit 1 = discontinue module operation when device enters idle mode. 0 = continue module operation in idle mode. if a device has multiple comparators, any cmpsidl bit set to ? 1 ? disables all comparators while in idle mode. bit 12-8 reserved: read as ? 0 ? bit 7-6 insel<1:0>: input source select for comparator bits 00 = select cmpxa input pin 01 = select cmpxb input pin 10 = select cmpxc input pin 11 = select cmpxd input pin bit 5 extref: enable external reference bit 1 = external source provides reference to dac 0 = internal reference sources provide source to dac bit 4 reserved: read as ? 0 ? bit 3 cmpstat: current state of comparator output including cmppol selection bit bit 2 reserved: read as ? 0 ? bit 1 cmppol: comparator output polarity control bit 1 = output is inverted 0 = output is non inverted bit 0 range: selects dac output voltage range bit 1 = high range: max dac value = av dd / 2, 2.5v @ 5 volt v dd 0 = low range: max dac value = internal reference, 1.2v +-1%
dspic30f1010/202x ds70178a-page 188 advance information ? 2006 microchip technology inc. register 17-2: comparator dac control register x (cmpdacx) u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 ? ? ? ? ? ?cmref<9:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 cmref<7:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-10 reserved: read as ? 0 ? these bits are reserved for possible future expansion of the dac from 10 bits to more bits. bit 9-0 cmref<9:0>: comparator reference voltage select bits 1111111111 = (cmref * v ref / 1024) or (cmref * av dd / 1024) volts depending on range bit 0000000000 = 0.0 volts
? 2006 microchip technology inc. advance information ds70178a-page 189 dspic30f1010/202x table 17-3: analog comparator control register map file name adr bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets cmpcon1 04c0 cmpon ? cmpsidl ? ? ? ? ? insel<1:0> extref ? cmpstat ? cmppol range 0000 cmpdac1 04c2 ? ? ? ? ? ? cmref<9:0> 0000 cmpcon2 04c4 cmpon ? cmpsidl ? ? ? ? ? insel<1:0> extref ? cmpstat ? cmppol range 0000 cmpdac2 04c6 ? ? ? ? ? ? cmref<9:0> 0000 cmpcon3 04c8 cmpon ? cmpsidl ? ? ? ? ? insel<1:0> extref ? cmpstat ? cmppol range 0000 cmpdac3 04ca ? ? ? ? ? ? cmref<9:0> 0000 cmpcon4 04cc cmpon ? cmpsidl ? ? ? ? ? insel<1:0> extref ? cmpstat ? cmppol range 0000 cmpdac4 04ce ? ? ? ? ? ? cmref<9:0> 0000
dspic30f1010/202x ds70178a-page 190 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 191 dspic30f1010/202x 18.0 system integration there are several features intended to maximize sys- tem reliability, minimize cost through elimination of external components, provide power-saving operating modes and offer code protection: ? oscillator selection ? reset: - power-on reset (por) - power-up timer (pwrt) - oscillator start-up timer (ost) ? watchdog timer (wdt) ? power-saving modes (sleep and idle) ? code protection ? unit id locations ? in-circuit serial programming (icsp) programming capability dspic30f devices have a watchdog timer, which can be permanently enabled via the configuration bits or can be software controlled. it runs off its own rc oscil- lator for added reliability. there are two timers that offer necessary delays on power-up. one is the oscillator start-up timer (ost), intended to keep the chip in reset until the crystal oscillator is stable. the other is the power-up timer (pwrt), which provides a delay on power-up only, designed to keep the part in reset mode while the power supply stabilizes. with these two timers on-chip, most applications need no external reset circuitry. sleep mode is designed to offer a very low-current power-down mode. the user can wake-up from sleep mode through external reset, watchdog timer wake- up or through an interrupt. several oscillator options are also made available to allow the part to fit a wide variety of applications. in the idle mode, the clock sources are still active, but the cpu is shut off. the rc oscillator option saves system cost, while the lp crystal option saves power. 18.1 oscillator system overview the dspic30f oscillator system has the following modules and features: ? various external and internal oscillator options as clock sources ? an on-chip pll to boost internal operating frequency ? a clock switching mechanism between various clock sources ? programmable clock postscaler for system power savings ? a fail-safe clock monitor (fscm) that detects clock failure and takes fail-safe measures ? clock control register osccon ? configuration bits for main oscillator selection configuration bits determine the clock source upon power-on reset (por). thereafter, the clock source can be changed between permissible clock sources. the osccon register controls the clock switching and reflects system clock related status bits. table 18-1 provides a summary of the dspic30f oscil- lator operating modes. a simplified diagram of the oscillator system is shown in figure 18-1. 18.2 oscillator control registers the oscillators are controlled with osccon, osc- tun, osctun2, fosc and the foscsel registers. note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). for more information on the device instruction set and pro- gramming, refer to the ? dspic30f/33f programmer?s reference manual? (ds70157). note: 32 khz crystal operation is not enabled on dspic30f1010/202x devices.
dspic30f1010/202x ds70178a-page 192 advance information ? 2006 microchip technology inc. register 18-1: osccon: oscillator control register u-0 r-y hs,hc r-y hs,hc r-y hs,hc u-0 r/w-y r/w-y r/w-y ?cosc<2:0> ?nosc<2:0> bit 15 bit 8 r/w-0 u-0 r-0 hs,hc r/w-0 r/c-0 hs,hc r/w-0 u-0 r/w-0 hc clklock ? lock prcden cf tseqen ? oswen bit 7 bit 0 legend: x = bit is unknown r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por hc = cleared by hardware ?1? = bit is set hs = set by hardware ?0? = bit is cleared -y = value set from configuration bits on por bit 15 unimplemented: read as ? 0 ? bit 14-12 cosc<2:0>: current oscillator group selection bits (read-only) 000 = fast rc oscillator (frc) 001 = fast rc oscillator (frc) with pll module 010 = primary oscillator (hs, ec) 011 = primary oscillator (hs, ec) with pll module 100 = reserved 101 = reserved 110 = reserved 111 = reserved this bit is reset upon: set to frc value (? 000 ?) on por loaded with nosc<2:0> at the completion of a successful clock switch set to frc value (? 000 ?) when fscm detects a failure and switches clock to frc bit 11 unimplemented: read as ? 0 ? bit 10-8 nosc<2:0>: new oscillator group selection bits 000 = fast rc oscillator (frc) 001 = fast rc oscillator (frc) with pll module 010 = primary oscillator (hs, ec) 011 = primary oscillator (hs, ec) with pll module 100 = reserved 101 = reserved 110 = reserved 111 = reserved bit 7 clklock: clock lock enabled bit 1 = if (fcksm1 = 1 ), then clock and pll configurations are locked if (fcksm1 = 0 ), then clock and pll configurations may be modified 0 = clock and pll selection are not locked, configurations may be modified note: once set, this bit can only be cleared via a reset. bit 6 unimplemented: read as ? 0 ?
? 2006 microchip technology inc. advance information ds70178a-page 193 dspic30f1010/202x bit 5 lock: pll lock status bit (read-only) 1 = indicates that pll is in lock 0 = indicates that pll is out of lock (or disabled) this bit is reset upon: reset on por reset when a valid clock switching sequence is initiated by the clock switch state machine set when pll lock is achieved after a pll start reset when lock is lost read zero when pll is not selected as a group 1 system clock bit 4 prcden: pseudo random clock dither enable bit 1 = pseudo random clock dither is enabled 0 = pseudo random clock dither is disabled. bit 3 cf: clock fail detect bit (read/clearable by application) 1 = fscm has detected clock failure 0 = fscm has not detected clock failure this bit is reset upon: reset on por reset when a valid clock switching sequence is initiated by the clock switch state machine set when clock fail detected bit 2 tseqen: frc tune sequencer enable bit 1 = the tun<3:0>, tseq1<3:0>, ... , tseq7<3:0> bits in the osctun and the osctun2 regis- ters sequentially tune the frc oscillator. each field being sequentially selected via the roll<2:0> signals from the pwm module. 0 = the tun<3:0> bits in osctun register tunes the frc oscillator. bit 1 unimplemented: read as ? 0 ? bit 0 oswen: oscillator switch enable bit 1 = request oscillator switch to selection specified by nosc<1:0> bits 0 = oscillator switch is complete this bit is reset upon: reset on por reset after a successful clock switch reset after a redundant clock switch reset after fscm switches the oscillator to (group 3) frc register 18-1: osccon: oscillator control register (continued)
dspic30f1010/202x ds70178a-page 194 advance information ? 2006 microchip technology inc. register 18-2: osctun: oscillator tuning register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tseq3<3:0> tseq2<3:0> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tseq1<3:0> tun<3:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-12 tseq3<3:0>: tune sequence value #3 bits when pwm roll<2:0> = 011 , this field is used to tune the frc instead of tun<3:0> bit 11-8 tseq2<3:0>: tune sequence value #2 bits when pwm roll<2:0> = 010 , this field is used to tune the frc instead of tun<3:0> bit 7-4 tseq1<3:0>: tune sequence value #1 bits when pwm roll<2:0> = 001 , this field is used to tune the frc instead of tun<3:0> bit 3-0 tun<3:0>: specifies the user tuning capability for the internal fast rc oscillator (nominal 15.0 mhz). if the tseqen bit in the osccon register is set, this field, along with bits tseq1-tseq7, will sequentially tune the frc oscillator. 0111 = maximum frequency 0110 = 0101 = 0100 = 0011 = 0010 = 0001 = 0000 = center frequency, oscillator is running at calibrated frequency 1111 = 1110 = 1101 = 1100 = 1011 = 1010 = 1001 = 1000 = minimum frequency
? 2006 microchip technology inc. advance information ds70178a-page 195 dspic30f1010/202x register 18-4: lfsr: linear feedback shift register register 18-3: osctun2: oscillator tuning register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tseq7<3:0> tseq6<3:0> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tseq5<3:0> tseq4<3:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15-12 tseq7<3:0>: tune sequence value #7 bits when pwm roll<2:0> = 111 , this field is used to tune the frc instead of tun<3:0> bit 11-8 tseq6<3:0>: tune sequence value #6 bits when pwm roll<2:0> = 110 , this field is used to tune the frc instead of tun<3:0> bit 7-4 tseq5<3:0>: tune sequence value #5 bits when pwm roll<2:0> = 101 , this field is used to tune the frc instead of tun<3:0> bit 3-0 tseq4<3:0>: tune sequence value #4 bits when pwm roll<2:0> = 100 , this field is used to tune the frc instead of tun<3:0> u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ?lfsr<14:8> bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 lfsr<7:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 15 unimplemented: read as ? 0 ? when ps pwm roll<2:0> = 111 , this field is used to tune the frc instead of tun<3:0> bit 14-8 lfsr <14:8>: most significant 7 bits of the pseudo random frc trim value bits bit 7-0 lfsr <7:0>: least significant 8 bits of the pseudo random frc trim value bits
dspic30f1010/202x ds70178a-page 196 advance information ? 2006 microchip technology inc. 18.2.1 protection against accidental writes to osccon register because the osccon register allows clock switching and clock scaling, a write to osccon is intentionally made difficult. to write to osccon low byte, this exact sequence must be executed without any other instructions in between: ? byte write ?46h? to osccon low ? byte write ?57h? to osccon low ? byte write is allowed for one instruction cycle. mov.b w0,osccon to write to osccon high byte, this exact sequence must be executed without any other instructions in between: ? byte write ?78h? to osccon high ? byte write ?9ah? to osccon high ? byte write is allowed for one instruction cycle. mov.b w0,osccon + 1
? 2006 microchip technology inc. advance information ds70178a-page 197 dspic30f1010/202x register 18-5: foscsel: oscillator selection configuration bits uuuuuuuu ? ? ? ? ? ? ? ? bit 23 bit 16 uuuuuuuu ? ? ? ? ? ? ? ? bit 15 bit 8 uuuuuur/pr/p ? ? ? ? ? ? fnosc1 fnosc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 23-2 unimplemented: read as ? 0 ? bit 1-0 fnosc<1:0>: initial oscillator group selection on por bits 00 = fast rc oscillator (frc) 01 = fast rc oscillator (frc) divided by n, with pll module. 10 = primary oscillator (hs,ec). 11 = primary oscillator (hs,ec) with pll module.
dspic30f1010/202x ds70178a-page 198 advance information ? 2006 microchip technology inc. scillator operating modes register 18-6: fosc: oscillator selection configuration bits uuuuuuuu ? ? ? ? ? ? ? ? bit 23 bit 16 uuuuuuuu ? ? ? ? ? ? ? ? bit 15 bit 8 r/p r/p r/p u u r/p r/p r/p fcksm<1:0> frange ? ? osciofnc poscmd<1:0> bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? -n = value at por ?1? = bit is set ?0? = bit is cleared x = bit is unknown bit 23-8 unimplemented: read as ? 0 ? bit 7-6 fcksm<1:0>: clock switching and monitor selection configuration bits 1x = clock switching is disabled, fail-safe clock monitor is disabled. 01 = clock switching is enabled, fail-safe clock monitor is disabled. 00 = clock switching is enabled, fail-safe clock monitor is enabled bit 5 frange: frequency range select for frc and pll bit acts like a ?gear shift? feature that enables the dspic dsc device to operate at reduced mips at a reduced supply voltage (3.3v) 0 = ?low range? (frc operates at a nominal 9.7 mhz, pll vco at a nominal 301 mhz (320 max)) 1 = ?high range? (frc operates at a nominal 14.55 mhz, pll vco at a nominal 451 mhz. (480 max)) bit 4-3 unimplemented: read as ? 0 ? bit 3 osciofnc: osc2 pin i/o enable bit 1 = clko output signal active on the osco pin. 0 = clko output disabled bit 1-0 poscmd<1:0>: primary oscillator mode 11 = primary oscillator disabled 10 = hs oscillator mode selected. 01 = reserved 00 = external clock mode selected.
? 2006 microchip technology inc. advance information ds70178a-page 199 dspic30f1010/202x figure 18-1: oscillator system block diagram primary osc1 osc2 oscillator clock and control block switching x32 pll primary oscillator stability detector programmable clock divider oscillator start-up timer fail-safe clock monitor (fscm) internal fast rc oscillator (frc) internal low-power rc oscillator (lprc) pwrsav instruction wake-up request oscillator configuration bits system clock oscillator trap por done primary osc f pll post<1:0> 2 fcksm<1:0> 2 pll lock cosc<1:0> nosc<1:0> oswen cf tun<3:0> 4 fpwm clock dither circuit
dspic30f1010/202x ds70178a-page 200 advance information ? 2006 microchip technology inc. 18.3 oscillator configurations 18.3.1 initial clock source selection while coming out of a power-on reset, the device selects its clock source based on: a) fnosc<1:0> configuration bits that select one of three oscillator groups (hs, ec or frc) b) poscmd1<1:0> configuration bits that select the primary oscillator mode c) osciofnc selects if the osc2 pin is an i/o or clock output the selection is as shown in table 18-1. table 18-1: configuration bit values for clock selection 18.3.2 oscillator start-up timer (ost) in order to ensure that a crystal oscillator (or ceramic resonator) has started and stabilized, an oscillator start-up timer is included. it is a simple 10-bit counter that counts 1024 t osc cycles before releasing the oscillator clock to the rest of the system. the time-out period is designated as t ost . the t ost time is involved every time the oscillator has to restart (i.e., on por and wake-up from sleep). the oscillator start-up timer is applied to the hs oscillator mode (upon wake-up from sleep and por) for the primary oscillator. 18.3.3 phase locked loop (pll) the pll multiplies the clock, which is generated by the primary oscillator. the pll is selectable to have a gain of x32 only. input and output frequency ranges are summarized in table 18-2. table 18-2: pll frequency range the pll features a lock output, which is asserted when the pll enters a phase locked state. should the loop fall out of lock (e.g., due to noise), the lock signal will be rescinded. the state of this signal is reflected in the read-only lock bit in the osccon register. oscillator mode oscillator source fnosc<1:0> poscmd<1:0> osciofnc osc2 function osc1 function bit 1 bit 0 bit 1 bit 0 hs w/pll 32x pll 11 1 0 n/a clkout (1) clki frc w/pll 32x pll 01 1 1 1 clkout i/o frc w/pll 32x pll 01 1 1 0 i/o i/o ec w/pll 32x pll 11 0 0 1 clkout clki ec w/pll 32x pll 11 0 0 0 i/o clki ec (2) external 10 0 0 1 clkout clki ec (2) external 10 0 0 0 i/o clki hs (2) external 10 1 0 n/a clkout (1) clki frc (2) internal rc 00 1 1 0 i/o i/o frc (2) internal rc 00 1 1 1 clkout i/o note 1: clkout is not recommended to drive external circuits. 2: this mode is not recommended for some applications; disabling 32x pll will not allow operation of high-speed adc and pwm. f in pll multiplier f out 9.7 mhz x32 310 mhz 14.55 mhz x32 466 mhz
? 2006 microchip technology inc. advance information ds70178a-page 201 dspic30f1010/202x 18.4 primary oscillator on osc1/ osc2 pins: the primary oscillator uses is shown in figure 18-2. figure 18-2: primary oscillator 18.5 external clock input two of the primary oscillator modes use an external clock. these modes are ec and ec with io. in the ec mode (figure 18-3), the osc1 pin can be driven by cmos drivers. in this mode, the osc1 pin is high-impedance and the osc2 pin is the clock output (f osc /2). this output clock is useful for testing or synchronization purposes. in the ec with io mode (figure 18-4), the osc1 pin can be driven by cmos drivers. in this mode, the osc1 pin is high-impedance and the osc2 pin becomes a general purpose i/o pin. the feedback device between osc1 and osc2 is turned off to save current. figure 18-3: external clock input operation (ec oscillator configuration) figure 18-4: external clock input operation (ecio oscillator configuration) c1 c2 xtal osc2/clko rs (1) osc1/clki r f (2) note 1: a series resistor, rs, may be required for at strip cut crystals. 2: the feedback resistor, r f , is typically in the range of 2 to 10 m . to c l k g e n clko/rc15 osc1 osc2 f osc /2 dspic30f clock from ext system osc1 i/o (osc2) i/o dspic30f clock from ext system
dspic30f1010/202x ds70178a-page 202 advance information ? 2006 microchip technology inc. 18.6 internal fast rc oscillator (frc) frc is a fast, precise frequency internal rc oscillator. the frc oscillator is designed to run at a frequency of 9.7/14.55 mhz (1% accuracy). the frc oscillator option is intended to be accurate enough to provide the clock frequency necessary to maintain baud rate tolerance for serial data transmissions. the user has the ability to tune the frc frequency by +-3%. the frc oscillator is powered: a) any time the ec or hs oscillator modes are not selected. b) when the fail-safe clock monitor is enabled and a clock fail is detected, forcing a switch to frc. 18.6.1 frequency range selection the frc module has a ?gear shift? control signal that selects ?low range? (9.7 mhz) or ?high range? (14.55 mhz) frequency of operation. this feature enables a dspic dsc device to operate at 3.3v/5.0v at 20/30 mips and remain with system specifications. 18.6.2 nominal frequency values the frc module is calibrated to a nominal 9.7 mhz in ?low range? and 14.55 mhz in ?high range? this fea- ture enables a user to ?tune? the dspic dsc device frequency of operation by +-3% and still remain within system specifications. 18.6.3 frc frequency user tuning the frc is calibrated at the factory to give a nominal 9.7/14.55 mhz. the tun<3:0> field in the osctun register is available to the user for trimming the frc oscillator frequency in applications. the 4-bit tuning control signals are supplied by the osctun or the osctun2 registers depending on the tseqen bit in the osccon register. the tuning range of the 15 mhz oscillator is 0.45 mhz (3%) nominal. the base frequency can be tuned in the user's appli- cation. this frequency tuning capability allows the user to deviate from the factory calibrated frequency. the user can tune the frequency by writing to the osctun register tun<3:0> bits. 18.6.4 clock dithering logic in power conversion applications, the primary electri- cal noise emission that the designers want to reduce is caused by the power transistors switching at the pwm frequency. by changing the system clock frequency of the smps dspic dsc, the resultant pwm frequency will change and the peak emi will be reduced at the noise is spread over a wider frequency range. typically, the range of frequency variation is few percent. the dspic30f1010/202x can provide two ways to vary system clock frequency on a pwm cycle basis. these are frequency sequencing mode and pseudo random clock dithering mode. table 18-5 shows the implementation details of both these methods. 18.6.5 frequency sequencing mode the frequency sequencing mode enables the pwm module to select a sequence of eight different frc tun values to vary the system frequency with each rollover of the primary pwm time base. the osctun and the osctun2 registers allow the user to specify eight sequential tune values if the tseqen bit is set in the osccon register. if the tseqen bit is zero, then only the tun bits affect the frc frequency. a 4-bit wide multiplexer with eight sets of inputs selects the tuning value from the tun and the tseqx bit fields. the multiplexer is controlled by the roll<5:3> counter in the pwm module. the roll<5:3> counter increments every time the primary time base rolls over after reaching the period value. 18.6.6 pseudo random clock dithering mode the pseudo random clock dither (prcd) logic is implemented with a 15-bit lfsr (linear feedback shift register), which is a shift register with a few exclusive or gates. the lower four bits of the lfsr provides the frc tune bits. the prcd feature is enabled by setting the prcden bit in the osccon register. the lsfr is ?clocked? (enabled to clock) once every time the roll<3> bit changes state, which occurs once every 8 pwm cycles. 18.6.7 fail-safe clock monitor the fail-safe clock monitor (fscm) allows the device to continue to operate even in the event of an oscillator failure. the fscm function is enabled by appropriately programming the fcksm configuration bits (clock switch and monitor selection bits) in the fosc configuration register. in the event of an oscillator failure, the fscm will generate a clock failure trap event and will switch the system clock over to the frc oscillator. the user will then have the option to either attempt to restart the oscillator or execute a controlled shutdown. the user may decide to treat the trap as a warm reset by sim- ply loading the reset address into the oscillator fail trap vector. in this event, the cf (clock fail) status bit (osccon<3>) is also set whenever a clock failure is recognized. in the event of a clock failure, the wdt is unaffected and continues to run on the lprc clock. if the oscillator has a very slow start-up time coming out of por or sleep, it is possible that the pwrt timer will expire before the oscillator has started. in such cases, the fscm will be activated and the fscm will
? 2006 microchip technology inc. advance information ds70178a-page 203 dspic30f1010/202x initiate a clock failure trap, and the cosc<2:0> bits are loaded with frc oscillator selection. this will effectively shut off the original oscillator that was trying to start. the user may detect this situation and restart the oscillator in the clock fail trap, isr. upon a clock failure detection, the fscm module will initiate a clock switch to the frc oscillator as follows: 1. the cosc bits (osccon<14:12>) are loaded with the frc oscillator selection value 2. cf bit is set (osccon<3>) 3. oswen control bit (osccon<0>) is cleared for the purpose of clock switching, the clock sources are sectioned into two groups: 1. primary 2. internal frc the user can switch between these functional groups, but cannot switch between options within a group. if the primary group is selected, then the choice within the group is always determined by the fnosc<1:0> configuration bits. the osccon register holds the control and status bits related to clock switching. if configuration bits fcksm<1:0> = 1x , then the clock switching and fail- safe clock monitor functions are disabled. this is the default configuration bit setting. if clock switching is disabled, then the fnosc<1:0> and poscmd<1:0> bits directly control the oscillator selection and the cosc<2:0> bits do not control the clock selection. however, these bits will reflect the clock source selection. 18.7 reset the dspic30f1010/202x differentiates between various kinds of reset: a) power-on reset (por) b) mclr reset during normal operation c) mclr reset during sleep d) watchdog timer (wdt) reset (during normal operation) e) reset instruction f) reset cause by trap lock-up (trapr) g) reset caused by illegal opcode, or by using an uninitialized w register as an address pointer (iopuwr) different registers are affected in different ways by var- ious reset conditions. most registers are not affected by a wdt wake-up, since this is viewed as the resump- tion of normal operation. status bits from the rcon register are set or cleared differently in different reset situations, as indicated in table 18-3. these bits are used in software to determine the nature of the reset. a block diagram of the on-chip reset circuit is shown in figure 18-6. a mclr noise filter is provided in the mclr reset path. the filter detects and ignores small pulses. internally generated resets do not drive mclr pin low. note: the application should not attempt to switch to a clock frequency lower than 100 khz when the fail-safe clock monitor is enabled. if clock switching is performed, the device may generate an oscillator fail trap and switch to the fast rc oscillator.
dspic30f1010/202x ds70178a-page 204 advance information ? 2006 microchip technology inc. figure 18-5: frc tune di ther logic block diagram figure 18-6: reset system block diagram d q clk 3 tune bits to frc all zero detect tseqen in osccon 15 roll<3> 0 1 tseq7 4 d q0 clk q d q1 clk q d q2 clk q d q3 clk q d q4 clk q d q5 clk q d q6 clk q d q7 clk q d q8 clk q d q9 clk q d q10 clk q d q11 clk q d q12 clk q d q13 clk q d q14 clk q lfsr pwm ps tseq6 tseq5 tseq4 0 15 osctun2 tseq3 tseq2 tseq1 tun 0 15 osctun 3 4 3 12 12 11 7 11 0 1 2 3 4 5 6 8 4 mux roll counter roll<5:3> roll<2:0> mux 4 shift enable for lfsr 4 prcden in osccon s r q mclr v dd v dd rise detect por sysrst sleep or idle wdt module digital glitch filter trap conflict illegal opcode/ uninitialized w register reset instruction
? 2006 microchip technology inc. advance information ds70178a-page 205 dspic30f1010/202x 18.7.1 por: power-on reset a power-on event will generate an internal por pulse when a v dd rise is detected. the reset pulse will occur at the por circuit threshold voltage (v por ), which is nominally 1.85v. the device supply voltage character- istics must meet specified starting voltage and rise rate requirements. the por pulse will reset a por timer and place the device in the reset state. the por also selects the device clock source identified by the oscillator configuration fuses. the por circuit inserts a small delay, t por , which is nominally 10 s and ensures that the device bias circuits are stable. furthermore, a user selected power- up time-out (t pwrt ) is applied. the t pwrt parameter is based on configuration bits and can be 0 ms (no delay), 4 ms, 16 ms or 64 ms. the total delay is at device power-up t por + t pwrt . when these delays have expired, sysrst will be negated on the next leading edge of the q1 clock, and the pc will jump to the reset vector. the timing for the sysrst signal is shown in figure 18-7 through figure 18-9. figure 18-7: time-out sequence on power-up (mclr tied to v dd ) figure 18-8: time-out sequence on power-up (mclr not tied to v dd ): case 1 t pwrt t ost v dd internal por pwrt time-out ost time-out internal reset mclr t pwrt t ost v dd internal por pwrt time-out ost time-out internal reset mclr
dspic30f1010/202x ds70178a-page 206 advance information ? 2006 microchip technology inc. figure 18-9: time-out sequence on power-up (mclr not tied to v dd ): case 2 18.7.1.1 por with long crystal start-up time (with fscm enabled) the oscillator start-up circuitry is not linked to the por circuitry. some crystal circuits (especially low frequency crystals) will have a relatively long start-up time. therefore, one or more of the following conditions is possible after the por timer and the pwrt have expired: ? the oscillator circuit has not begun to oscillate. ? the oscillator start-up timer has not expired (if a crystal oscillator is used). ? the pll has not achieved a lock (if pll is used). if the fscm is enabled and one of the above conditions is true, then a clock failure trap will occur. the device will automatically switch to the frc oscillator and the user can switch to the desired crystal oscillator in the trap, isr. 18.7.1.2 operating without fscm and pwrt if the fscm is disabled and the power-up timer (pwrt) is also disabled, then the device will exit rap- idly from reset on power-up. if the clock source is frc or ec, it will be active immediately. if the fscm is disabled and the system clock has not started, the device will be in a frozen state at the reset vector until the system clock starts. from the user?s perspective, the device will appear to be in reset until a system clock is available. figure 18-10: external power-on reset circuit (for slow v dd power-up) v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost note: dedicated supervisory devices, such as the mcp1xx and mcp8xx, may also be used as an external power-on reset circuit. note 1: external power-on reset circuit is required only if the v dd power-up slope is too slow. the diode d helps discharge the capacitor quickly when v dd powers down. 2: r should be suitably chosen so as to make sure that the voltage drop across r does not violate the device?s electrical specification. 3: r1 should be suitably chosen so as to limit any current flowing into mclr from external capacitor c, in the event of mclr /v pp pin breakdown due to elec- trostatic discharge (esd) or electrical overstress (eos). c r1 r d v dd dspic30f mclr
? 2006 microchip technology inc. advance information ds70178a-page 207 dspic30f1010/202x table 18-3 shows the reset conditions for the rcon register. since the control bits within the rcon register are r/w, the information in the table implies that all the bits are negated prior to the action specified in the condition column. table 18-3: initialization condition for rcon register case 1 table 18-4 shows a second example of the bit conditions for the rcon register. in this case, it is not assumed the user has set/cleared specific bits prior to action specified in the condition column. table 18-4: initialization condition for rcon register case 2 condition program counter trapr iopuwr extr swr wdto idle sleep por power-on reset 0x000000 00000001 mclr reset during normal operation 0x000000 00100000 software reset during normal operation 0x000000 00010000 mclr reset during sleep 0x000000 00100010 mclr reset during idle 0x000000 00100100 wdt time-out reset 0x000000 00001000 wdt wake-up pc + 2 00001010 interrupt wake-up from sleep pc + 2 (1) 00000010 clock failure trap 0x000004 00000000 trap reset 0x000000 10000000 illegal operation trap 0x000000 01000000 note 1: when the wake-up is due to an enabled interrupt, the pc is loaded with the corresponding interrupt vector. condition program counter trapr iopuwr extr swr wdto idle sleep por power-on reset 0x000000 0000000 1 mclr reset during normal operation 0x000000 uu10000 u software reset during normal operation 0x000000 uu01000 u mclr reset during sleep 0x000000 uu1u001 u mclr reset during idle 0x000000 uu1u010 u wdt time-out reset 0x000000 uu00100 u wdt wake-up pc + 2 uuuu1u1 u interrupt wake-up from sleep pc + 2 (1) uuuuuu1 u clock failure trap 0x000004 uuuuuuu u trap reset 0x000000 1uuuuuu u illegal operation reset 0x000000 u1uuuuu u legend: u = unchanged note 1: when the wake-up is due to an enabled interrupt, the pc is loaded with the corresponding interrupt vector.
dspic30f1010/202x ds70178a-page 208 advance information ? 2006 microchip technology inc. 18.8 watchdog timer (wdt) 18.8.1 watchdog timer operation the primary function of the watchdog timer (wdt) is to reset the processor in the event of a software malfunction. the wdt is a free-running timer, which runs off an on-chip rc oscillator, requiring no external component. therefore, the wdt timer will continue to operate even if the main processor clock (e.g., the crystal oscillator) fails. 18.8.2 enabling and disabling the wdt the watchdog timer can be ?enabled? or ?disabled? only through a configuration bit (fwdten) in the configuration register fwdt. setting fwdten = 1 enables the watchdog timer. the enabling is done when programming the device. by default, after chip-erase, fwdten bit = 1 . any device programmer capable of programming dspic30f devices allows programming of this and other configuration bits. if enabled, the wdt will increment until it overflows or ?times out?. a wdt time-out will force a device reset (except during sleep). to prevent a wdt time-out, the user must clear the watchdog timer using a clrwdt instruction. if a wdt times out during sleep, the device will wake- up. the wdto bit in the rcon register will be cleared to indicate a wake-up resulting from a wdt time-out. setting fwdten = 0 allows user software to enable/ disable the watchdog timer via the swdten (rcon<5>) control bit. 18.9 power-saving modes there are two power-saving states that can be entered through the execution of a special instruction, pwrsav . these are: sleep and idle. the format of the pwrsav instruction is as follows: pwrsav , where ? parameter ? defines idle or sleep mode. 18.9.1 sleep mode in sleep mode, the clock to the cpu and peripherals is shutdown. if an on-chip oscillator is being used, it is shutdown. the fail-safe clock monitor is not functional during sleep, since there is no clock to monitor. however, lprc clock remains active if wdt is operational during sleep. the processor wakes up from sleep if at least one of the following conditions has occurred: ? any interrupt that is individually enabled and meets the required priority level ? any reset (por and mclr ) ? wdt time-out on waking up from sleep mode, the processor will restart the same clock that was active prior to entry into sleep mode. when clock switching is enabled, bits cosc<2:0> will determine the oscillator source that will be used on wake-up. if clock switch is disabled, then there is only one system clock. if the clock source is an oscillator, the clock to the device is held off until ost times out (indicating a sta- ble oscillator). if pll is used, the system clock is held off until lock = 1 (indicating that the pll is stable). either way, t por , t lock and t pwrt delays are applied . if ec, frc, oscillators are used, then a delay of t por (~10 s) is applied. this is the smallest delay possible on wake-up from sleep. moreover, if lp oscillator was active during sleep, and lp is the oscillator used on wake-up, then the start-up delay will be equal to t por . pwrt delay and ost timer delay are not applied. in order to have the small- est possible start-up delay when waking up from sleep, one of these faster wake-up options should be selected before entering sleep. any interrupt that is individually enabled (using the corresponding ie bit) and meets the prevailing priority level will be able to wake-up the processor. the proces- sor will process the interrupt and branch to the isr. the sleep status bit in the rcon register is set upon wake-up . all resets will wake-up the processor from sleep mode. any reset, other than por, will set the sleep status bit. in a por, the sleep bit is cleared. if watchdog timer is enabled, then the processor will wake-up from sleep mode upon wdt time-out. the sleep and wdto status bits are both set. note: if a por occurred, the selection of the oscillator is based on the fgs<2:0> and fpg<1:0> configuration bits. note: in spite of various delays applied (t por , t lock and t pwrt ), the crystal oscillator (and pll) may not be active at the end of the time-out (e.g., for low frequency crys- tals). in such cases, if fscm is enabled, the device will detect this as a clock failure and process the clock failure trap, the frc oscillator will be enabled, and the user will have to re-enable the crystal oscillator. if fscm is not enabled, then the device will simply suspend execution of code until the clock is stable, and will remain in sleep until the oscillator clock has started.
? 2006 microchip technology inc. advance information ds70178a-page 209 dspic30f1010/202x 18.9.2 idle mode in idle mode, the clock to the cpu is shutdown while peripherals keep running. unlike sleep mode, the clock source remains active. several peripherals have a control bit in each module that allows them to operate during idle. lprc fail-safe clock remains active if clock failure detect is enabled. the processor wakes up from idle if at least one of the following conditions is true: ? on any interrupt that is individually enabled (ie bit is ? 1 ?) and meets the required priority level ? on any reset (por, m clr ) ? on wdt time-out upon wake-up from idle mode, the clock is re-applied to the cpu and instruction execution begins immedi- ately, starting with the instruction following the pwrsav instruction. any interrupt that is individually enabled (using ie bit) and meets the prevailing priority level will be able to wake-up the processor. the processor will process the interrupt and branch to the isr. the idle status bit in rcon register is set upon wake-up. any reset, other than por, will set the idle status bit. on a por, the idle bit is cleared. if watchdog timer is enabled, then the processor will wake-up from idle mode upon wdt time-out. the idle and wdto status bits are both set. unlike wake-up from sleep, there are no time delays involved in wake-up from idle. 18.10 device configuration registers the configuration bits in each device configuration register specify some of the device modes and are programmed by a device programmer, or by using the in-circuit serial programming (icsp) feature of the device. each device configuration register is a 24-bit register, but only the lower 16 bits of each register are used to hold configuration data. there are four configuration registers available to the user: 1. fosc (0xf80000): oscillator configuration register 2. fwdt (0xf80002): watchdog timer configuration register 3. fgs (0xf8000a): general code segment configuration register the placement of the configuration bits is automati- cally handled when you select the device in your device programmer. the desired state of the configuration bits may be specified in the source code (dependent on the language tool used), or through the programming interface. after the device has been programmed, the application software may read the configuration bit values through the table read instructions. for addi- tional information, please refer to the programming specifications of the device. note: if the code protection configuration fuse bits (fgs and fgs) have been programmed, an erase of the entire code-protected device is only possible at voltages v dd 4.5v.
dspic30f1010/202x ds70178a-page 210 advance information ? 2006 microchip technology inc. 18.11 in-circuit debugger when mplab ? icd 2 is selected as a debugger, the in-circuit debugging functionality is enabled. this func- tion allows simple debugging functions when used with mplab ide. when the device has this feature enabled, some of the resources are not available for general use. these resources include the first 80 bytes of data ram and two i/o pins. one of four pairs of debug i/o pins may be selected by the user using configuration options in mplab ide. these pin pairs are named emud/emuc, emud1/ emuc1, emud2/emuc2 and emud3/emuc3. in each case, the selected emud pin is the emulation/ debug data line, and the emuc pin is the emulation/ debug clock line. these pins will interface to the mplab icd 2 module available from microchip. the selected pair of debug i/o pins is used by mplab icd 2 to send commands and receive responses, as well as to send and receive data. to use the in-circuit debugging function of the device, the design must implement icsp connections to mclr , v dd , v ss , pgc, pgd and the selected emudx/emucx pin pair. this gives rise to two possibilities: 1. if emud/emuc is selected as the debug i/o pin pair, then only a 5-pin interface is required, as the emud and emuc pin functions are multi- plexed with the pgd and pgc pin functions in all dspic30f devices. 2. if emud1/emuc1, em ud2/emuc2 or emud3/ emuc3 is selected as the debug i/o pin pair, then a 7-pin interface is required, as the emudx/emucx pin functions (x = 1, 2 or 3) are not multiplexed with the pgd and pgc pin functions.
? 2006 microchip technology inc. advance information ds70178a-page 211 dspic30f1010/202x table 18-5: system integration register map for dspic30f202x table 18-6: device configuration register map sfr name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 reset state rcon 0740 trapr iopuwr ? ? ? ? ? ? extr swr swdten wdto sleep idle ? por depends on type of reset. osccon 0742 ?cosc<2:0> ? nosc<2:0> clklock ? lock prcden cf tseqen ?oswen depends on configuration bits. osctun 0748 tseq3<3:0> tseq2<3:0> tseq1<3:0> tun<3:0> 0000 0000 0000 0000 osctun2 074a tseq7<3:0> tseq6<3:0> tseq5<3:0> tseq4< 3:0 > 0000 0000 0000 0000 lfsr 074c ? lfsr<14:0> 0000 0000 0000 0000 pmd1 0770 ? ? t3md t2md t1md ?pwmmd ?i2cmd ?u1md ? spi1md ? ? adcmd 0000 0000 0000 0000 pmd2 0772 ? ? ? ? ? ? ?ic1md ? ? ? ? ? ?oc2mdoc1md 0000 0000 0000 0000 pmd3 0774 ? ? ? ? cmp_psmd ? ? ? ? ? ? ? ? ? ? ? 0000 0000 0000 0000 note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields. file name addr. bits 23-16 bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 fosc f80008 ? ? ? ? ? ? ? ? ? fcksm<1:0> frange ? ? osciofnc poscmd<1:0> fwdt f8000a ? ? ? ? ? ? ? ? ? fwdten wwdten ? fwpsa0 wdtps<3:0> fpor f8000c ? ? ? ? ? ? ? ? ? ? ? ? ? ?fpwrt<2:0> fgs f80004 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? gss0 gwrp foscsel f80006 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?fnosc<1:0> note: refer to the ? dspic30f family reference manual? (ds70046) for descriptions of register bit fields.
dspic30f1010/202x ds70178a-page 212 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 213 dspic30f1010/202x 19.0 instruction set summary the dspic30f instruction set adds many enhancements to the previous picmicro ? mcu instruction sets, while maintaining an easy migration from picmicro mcu instruction sets. most instructions are a single program memory word (24 bits). only three instructions require two program memory locations. each single-word instruction is a 24-bit word divided into an 8-bit opcode which specifies the instruction type, and one or more operands which further specify the operation of the instruction. the instruction set is highly orthogonal and is grouped into five basic categories: ? word or byte-oriented operations ? bit-oriented operations ? literal operations ? dsp operations ? control operations table 19-1 shows the general symbols used in describing the instructions. the dspic30f instruction set summary in table 19-2 lists all the instructions along with the status flags affected by each instruction. most word or byte-oriented w register instructions (including barrel shift instructions) have three operands: ? the first source operand, which is typically a register ?wb? without any address modifier ? the second source operand, which is typically a register ?ws? with or without an address modifier ? the destination of the result, which is typically a register ?wd? with or without an address modifier however, word or byte-oriented file register instructions have two operands: ? the file register specified by the value ?f? ? the destination, which could either be the file register ?f? or the w0 register, which is denoted as ?wreg? most bit-oriented instructions (including simple rotate/ shift instructions) have two operands: ? the w register (with or without an address modi- fier) or file register (specified by the value of ?ws? or ?f?) ? the bit in the w register or file register (specified by a literal value, or indirectly by the contents of register ?wb?) the literal instructions that involve data movement may use some of the following operands: ? a literal value to be loaded into a w register or file register (specified by the value of ?k?) ? the w register or file register where the literal value is to be loaded (specified by ?wb? or ?f?) however, literal instructions that involve arithmetic or logical operations use some of the following operands: ? the first source operand, which is a register ?wb? without any address modifier ? the second source operand, which is a literal value ? the destination of the result (only if not the same as the first source operand), which is typically a register ?wd? with or without an address modifier the mac class of dsp instructions may use some of the following operands: ? the accumulator (a or b) to be used (required operand) ? the w registers to be used as the two operands ? the x and y address space prefetch operations ? the x and y address space prefetch destinations ? the accumulator write back destination the other dsp instructions do not involve any multiplication, and may include: ? the accumulator to be used (required) ? the source or destination operand (designated as wso or wdo, respectively) with or without an address modifier ? the amount of shift, specified by a w register ?wn? or a literal value the control instructions may use some of the following operands: ? a program memory address ? the mode of the table read and table write instructions all instructions are a single word, except for certain double word instructions, which were made double word instructions so that all the required information is available in these 48 bits. in the second word, the 8msbs are ? 0 ?s. if this second word is executed as an instruction (by itself), it will execute as a nop . note: this data sheet summarizes features of this group of dspic30f devices and is not intended to be a complete reference source. for more information on the cpu, peripherals, register descriptions and general device functionality, refer to the ? dspic30f family reference manual ? (ds70046). for more information on the device instruction set and programming, refer to the ? dspic30f/ 33f programmer?s reference manual? (ds70157).
dspic30f1010/202x ds70178a-page 214 advance information ? 2006 microchip technology inc. most single-word instructions are executed in a single instruction cycle, unless a conditional test is true or the program counter is changed as a result of the instruc- tion. in these cases, the execution takes two instruction cycles with the additional instruction cycle(s) executed as a nop . notable exceptions are the bra (uncondi- tional/computed branch), indirect call/goto , all table reads and writes and return/retfie instruc- tions, which are single-word instructions, but take two or three cycles. certain instructions that involve skipping over the subsequent instruction, require either two or three cycles if the skip is performed, depending on whether the instruction being skipped is a single- word or two-word instruction. moreover, double word moves require two cycles. the double word instructions execute in two instruction cycles. note: for more details on the instruction set, refer to the ? dspic30f/33f programmer?s reference manual? (ds70157). table 19-1: symbols used in opcode descriptions field description #text means literal defined by ? text ? (text) means ?content of text ? [text] means ?the location addressed by text ? { } optional field or operation register bit field .b byte mode selection .d double word mode selection .s shadow register select .w word mode selection (default) acc one of two accumulators {a, b} awb accumulator write back destination address register {w13, [w13] + = 2} bit4 4-bit bit selection field (used in word addressed instructions) {0...15} c, dc, n, ov, z mcu status bits: carry, digit carry, negative, overflow, zero expr absolute address, label or expression (resolved by the linker) f file register address {0x0000...0x1fff} lit1 1-bit unsigned literal {0,1} lit4 4-bit unsigned literal {0...15} lit5 5-bit unsigned literal {0...31} lit8 8-bit unsigned literal {0...255} lit10 10-bit unsigned literal {0...255} for byte mode, {0:1023} for word mode lit14 14-bit unsigned literal {0...16384} lit16 16-bit unsigned literal {0...65535} lit23 23-bit unsigned literal {0...8388608}; lsb must be ? 0 ? none field does not require an entry, may be blank oa, ob, sa, sb dsp status bits: acca overflow, accb overflow, acca saturate, accb saturate pc program counter slit10 10-bit signed literal {-512...511} slit16 16-bit signed literal {-32768...32767} slit6 6-bit signed literal {-16...16}
? 2006 microchip technology inc. advance information ds70178a-page 215 dspic30f1010/202x wb base w register {w0..w15} wd destination w register { wd, [wd], [wd++], [wd--], [++wd], [--wd] } wdo destination w register { wnd, [wnd], [wnd++], [wnd--], [++wnd], [--wnd], [wnd+wb] } wm,wn dividend, divisor working register pair (direct addressing) wm*wm multiplicand and multiplier working register pair for square instructions {w4 * w4,w5 * w5,w6 * w6,w7 * w7} wm*wn multiplicand and multiplier working register pair for dsp instructions {w4 * w5,w4 * w6,w4 * w7,w5 * w6,w5 * w7,w6 * w7} wn one of 16 working registers {w0..w15} wnd one of 16 destination working registers {w0..w15} wns one of 16 source working registers {w0..w15} wreg w0 (working register used in file register instructions) ws source w register { ws, [ws], [ws++], [ws--], [++ws], [--ws] } wso source w register { wns, [wns], [wns++], [wns--], [++wns], [--wns], [wns+wb] } wx x data space prefetch address register for dsp instructions {[w8] + = 6, [w8] + = 4, [w8] + = 2, [w8], [w8] ? = 6, [w8] ? = 4, [w8] ? = 2, [w9] + = 6, [w9] + = 4, [w9] + = 2, [w9], [w9] ? = 6, [w9] ? = 4, [w9] ? = 2, [w9 + w12],none} wxd x data space prefetch destination register for dsp instructions {w4..w7} wy y data space prefetch address register for dsp instructions {[w10] + = 6, [w10] + = 4, [w10] + = 2, [w10], [w10] - = 6, [w10] - = 4, [w10] - = 2, [w11] + = 6, [w11] + = 4, [w11] + = 2, [w11], [w11] ? = 6, [w11] ? = 4, [w11] ? = 2, [w11 + w12], none} wyd y data space prefetch destination register for dsp instructions {w4..w7} table 19-1: symbols used in opcode descriptions (continued) field description
dspic30f1010/202x ds70178a-page 216 advance information ? 2006 microchip technology inc. table 19-2: instruction set overview base instr # assembly mnemonic assembly syntax description # of word s # of cycles status flags affected 1 add add acc add accumulators 1 1 oa,ob,sa,sb add f f = f + wreg 1 1 c,dc,n,ov,z add f,wreg wreg = f + wreg 1 1 c,dc,n,ov,z add #lit10,wn wd = lit10 + wd 1 1 c,dc,n,ov,z add wb,ws,wd wd = wb + ws 1 1 c,dc,n,ov,z add wb,#lit5,wd wd = wb + lit5 1 1 c,dc,n,ov,z add wso,#slit4,acc 16-bit signed add to accumulator 1 1 oa,ob,sa,sb 2 addc addc f f = f + wreg + (c) 1 1 c,dc,n,ov,z addc f,wreg wreg = f + wreg + (c) 1 1 c,dc,n,ov,z addc #lit10,wn wd = lit10 + wd + (c) 1 1 c,dc,n,ov,z addc wb,ws,wd wd = wb + ws + (c) 1 1 c,dc,n,ov,z addc wb,#lit5,wd wd = wb + lit5 + (c) 1 1 c,dc,n,ov,z 3 and and f f = f .and. wreg 1 1 n,z and f,wreg wreg = f .and. wreg 1 1 n,z and #lit10,wn wd = lit10 .and. wd 1 1 n,z and wb,ws,wd wd = wb .and. ws 1 1 n,z and wb,#lit5,wd wd = wb .and. lit5 1 1 n,z 4 asr asr f f = arithmetic right shift f 1 1 c,n,ov,z asr f,wreg wreg = arithmetic right shift f 1 1 c,n,ov,z asr ws,wd wd = arithmetic right shift ws 1 1 c,n,ov,z asr wb,wns,wnd wnd = arithmetic right shift wb by wns 1 1 n,z asr wb,#lit5,wnd wnd = arithmetic right shift wb by lit5 1 1 n,z 5 bclr bclr f,#bit4 bit clear f 1 1 none bclr ws,#bit4 bit clear ws 1 1 none 6 bra bra c,expr branch if carry 1 1 (2) none bra ge,expr branch if greater than or equal 1 1 (2) none bra geu,expr branch if unsigned greater than or equal 1 1 (2) none bra gt,expr branch if greater than 1 1 (2) none bra gtu,expr branch if unsigned greater than 1 1 (2) none bra le,expr branch if less than or equal 1 1 (2) none bra leu,expr branch if unsigned less than or equal 1 1 (2) none bra lt,expr branch if less than 1 1 (2) none bra ltu,expr branch if unsigned less than 1 1 (2) none bra n,expr branch if negative 1 1 (2) none bra nc,expr branch if not carry 1 1 (2) none bra nn,expr branch if not negative 1 1 (2) none bra nov,expr branch if not overflow 1 1 (2) none bra nz,expr branch if not zero 1 1 (2) none bra oa,expr branch if accumulator a overflow 1 1 (2) none bra ob,expr branch if accumulator b overflow 1 1 (2) none bra ov,expr branch if overflow 1 1 (2) none bra sa,expr branch if accumulator a saturated 1 1 (2) none bra sb,expr branch if accumulator b saturated 1 1 (2) none bra expr branch unconditionally 1 2 none bra z,expr branch if zero 1 1 (2) none bra wn computed branch 1 2 none 7 bset bset f,#bit4 bit set f 1 1 none bset ws,#bit4 bit set ws 1 1 none 8 bsw bsw.c ws,wb write c bit to ws 1 1 none bsw.z ws,wb write z bit to ws 1 1 none 9 btg btg f,#bit4 bit toggle f 1 1 none btg ws,#bit4 bit toggle ws 1 1 none 10 btsc btsc f,#bit4 bit test f, skip if clear 1 1 (2 or 3) none btsc ws,#bit4 bit test ws, skip if clear 1 1 (2 or 3) none
? 2006 microchip technology inc. advance information ds70178a-page 217 dspic30f1010/202x 11 btss btss f,#bit4 bit test f, skip if set 1 1 (2 or 3) none btss ws,#bit4 bit test ws, skip if set 1 1 (2 or 3) none 12 btst btst f,#bit4 bit test f 1 1 z btst.c ws,#bit4 bit test ws to c 1 1 c btst.z ws,#bit4 bit test ws to z 1 1 z btst.c ws,wb bit test ws to c 1 1 c btst.z ws,wb bit test ws to z 1 1 z 13 btsts btsts f,#bit4 bit test then set f 1 1 z btsts.c ws,#bit4 bit test ws to c, then set 1 1 c btsts.z ws,#bit4 bit test ws to z, then set 1 1 z 14 call call lit23 call subroutine 2 2 none call wn call indirect subroutine 1 2 none 15 clr clr f f = 0x0000 1 1 none clr wreg wreg = 0x0000 1 1 none clr ws ws = 0x0000 1 1 none clr acc,wx,wxd,wy,wyd,awb clear accumulator 1 1 oa,ob,sa,sb 16 clrwdt clrwdt clear watchdog timer 1 1 wdto,sleep 17 com com f f = f 11n,z com f,wreg wreg = f 11n,z com ws,wd wd = ws 11n,z 18 cp cp f compare f with wreg 1 1 c,dc,n,ov,z cp wb,#lit5 compare wb with lit5 1 1 c,dc,n,ov,z cp wb,ws compare wb with ws (wb ? ws) 1 1 c,dc,n,ov,z 19 cp0 cp0 f compare f with 0x0000 1 1 c,dc,n,ov,z cp0 ws compare ws with 0x0000 1 1 c,dc,n,ov,z 20 cpb cpb f compare f with wreg, with borrow 1 1 c,dc,n,ov,z cpb wb,#lit5 compare wb with lit5, with borrow 1 1 c,dc,n,ov,z cpb wb,ws compare wb with ws, with borrow (wb ? ws ? c ) 1 1 c,dc,n,ov,z 21 cpseq cpseq wb, wn compare wb with wn, skip if = 1 1 (2 or 3) none 22 cpsgt cpsgt wb, wn compare wb with wn, skip if > 1 1 (2 or 3) none 23 cpslt cpslt wb, wn compare wb with wn, skip if < 1 1 (2 or 3) none 24 cpsne cpsne wb, wn compare wb with wn, skip if 11 (2 or 3) none 25 daw daw wn wn = decimal adjust wn 1 1 c 26 dec dec f f = f ?1 1 1 c,dc,n,ov,z dec f,wreg wreg = f ?1 1 1 c,dc,n,ov,z dec ws,wd wd = ws ? 1 1 1 c,dc,n,ov,z 27 dec2 dec2 f f = f ?2 1 1 c,dc,n,ov,z dec2 f,wreg wreg = f ? 2 1 1 c,dc,n,ov,z dec2 ws,wd wd = ws ? 2 1 1 c,dc,n,ov,z 28 disi disi #lit14 disable interrupts for k instruction cycles 1 1 none 29 div div.s wm,wn signed 16/16-bit integer divide 1 18 n,z,c, ov div.sd wm,wn signed 32/16-bit integer divide 1 18 n,z,c, ov div.u wm,wn unsigned 16/16-bit integer divide 1 18 n,z,c, ov div.ud wm,wn unsigned 32/16-bit integer divide 1 18 n,z,c, ov 30 divf divf wm,wn signed 16/16-bit fractional divide 1 18 n,z,c, ov 31 do do #lit14,expr do code to pc + expr, lit14 + 1 times 2 2 none do wn,expr do code to pc + expr, (wn) + 1 times 2 2 none 32 ed ed wm * wm,acc,wx,wy,wxd euclidean distance (no accumulate) 1 1 oa,ob,oab, sa,sb,sab 33 edac edac wm * wm,acc,wx,wy,wxd euclidean distance 1 1 oa,ob,oab, sa,sb,sab table 19-2: instruction set overview (continued) base instr # assembly mnemonic assembly syntax description # of word s # of cycles status flags affected
dspic30f1010/202x ds70178a-page 218 advance information ? 2006 microchip technology inc. 34 exch exch wns,wnd swap wns with wnd 1 1 none 35 fbcl fbcl ws,wnd find bit change from left (msb) side 1 1 c 36 ff1l ff1l ws,wnd find first one from left (msb) side 1 1 c 37 ff1r ff1r ws,wnd find first one from right (lsb) side 1 1 c 38 goto goto expr go to address 2 2 none goto wn go to indirect 1 2 none 39 inc inc f f = f + 1 1 1 c,dc,n,ov,z inc f,wreg wreg = f + 1 1 1 c,dc,n,ov,z inc ws,wd wd = ws + 1 1 1 c,dc,n,ov,z 40 inc2 inc2 f f = f + 2 1 1 c,dc,n,ov,z inc2 f,wreg wreg = f + 2 1 1 c,dc,n,ov,z inc2 ws,wd wd = ws + 2 1 1 c,dc,n,ov,z 41 ior ior f f = f .ior. wreg 1 1 n,z ior f,wreg wreg = f .ior. wreg 1 1 n,z ior #lit10,wn wd = lit10 .ior. wd 1 1 n,z ior wb,ws,wd wd = wb .ior. ws 1 1 n,z ior wb,#lit5,wd wd = wb .ior. lit5 1 1 n,z 42 lac lac wso,#slit4,acc load accumulator 1 1 oa,ob,oab, sa,sb,sab 43 lnk lnk #lit14 link frame pointer 1 1 none 44 lsr lsr f f = logical right shift f 1 1 c,n,ov,z lsr f,wreg wreg = logical right shift f 1 1 c,n,ov,z lsr ws,wd wd = logical right shift ws 1 1 c,n,ov,z lsr wb,wns,wnd wnd = logical right shift wb by wns 1 1 n,z lsr wb,#lit5,wnd wnd = logical right shift wb by lit5 1 1 n,z 45 mac mac wm * wn,acc,wx,wxd,wy,wyd, awb multiply and accumulate 1 1 oa,ob,oab, sa,sb,sab mac wm * wm,acc,wx,wxd,wy,wyd square and accumulate 1 1 oa,ob,oab, sa,sb,sab 46 mov mov f,wn move f to wn 1 1 none mov f move f to f 1 1 n,z mov f,wreg move f to wreg 1 1 n,z mov #lit16,wn move 16-bit literal to wn 1 1 none mov.b #lit8,wn move 8-bit literal to wn 1 1 none mov wn,f move wn to f 1 1 none mov wso,wdo move ws to wd 1 1 none mov wreg,f move wreg to f 1 1 n,z mov.d wns,wd move double from w(ns):w(ns + 1) to wd 1 2 none mov.d ws,wnd move double from ws to w(nd + 1):w(nd) 1 2 none 47 movsac movsac acc,wx,wxd,wy,wyd,awb prefetch and store accumulator 1 1 none 48 mpy mpy wm * wn,acc,wx,wxd,wy,wyd multiply wm by wn to accumulator 1 1 oa,ob,oab, sa,sb,sab mpy wm * wm,acc,wx,wxd,wy,wyd square wm to accumulator 1 1 oa,ob,oab, sa,sb,sab 49 mpy.n mpy.n wm * wn,acc,wx,wxd,wy,wyd -(multiply wm by wn) to accumulator 1 1 none 50 msc msc wm * wm,acc,wx,wxd,wy,wyd, awb multiply and subtract from accumulator 1 1 oa,ob,oab, sa,sb,sab 51 mul mul.ss wb,ws,wnd {wnd + 1, wnd} = signed(wb) * signed(ws) 1 1 none mul.su wb,ws,wnd {wnd + 1, wnd} = signed(wb) * unsigned(ws) 1 1 none mul.us wb,ws,wnd {wnd + 1, wnd} = unsigned(wb) * signed(ws) 1 1 none mul.uu wb,ws,wnd {wnd + 1, wnd} = unsigned(wb) * unsigned(ws) 11none mul.su wb,#lit5,wnd {wnd + 1, wnd} = signed(wb) * unsigned(lit5) 1 1 none mul.uu wb,#lit5,wnd {wnd + 1, wnd} = unsigned(wb) * unsigned(lit5) 11none mul f w3:w2 = f * wreg 1 1 none table 19-2: instruction set overview (continued) base instr # assembly mnemonic assembly syntax description # of word s # of cycles status flags affected
? 2006 microchip technology inc. advance information ds70178a-page 219 dspic30f1010/202x 52 neg neg acc negate accumulator 1 1 oa,ob,oab, sa,sb,sab neg f f = f + 1 1 1 c,dc,n,ov,z neg f,wreg wreg = f + 1 1 1 c,dc,n,ov,z neg ws,wd wd = ws + 1 1 1 c,dc,n,ov,z 53 nop nop no operation 1 1 none nopr no operation 1 1 none 54 pop pop f pop f from top-of-stack (tos) 1 1 none pop wdo pop from top-of-stack (tos) to wdo 1 1 none pop.d wnd pop from top-of-stack (tos) to w(nd):w(nd + 1) 12none pop.s pop shadow registers 1 1 all 55 push push f push f to top-of-stack (tos) 1 1 none push wso push wso to top-of-stack (tos) 1 1 none push.d wns push w(ns):w(ns + 1) to top-of-stack (tos) 1 2 none push.s push shadow registers 1 1 none 56 pwrsav pwrsav #lit1 go into sleep or idle mode 1 1 wdto,sleep 57 rcall rcall expr relative call 1 2 none rcall wn computed call 1 2 none 58 repeat repeat #lit14 repeat next instruction lit14 + 1 times 1 1 none repeat wn repeat next instruction (wn) + 1 times 1 1 none 59 reset reset software device reset 1 1 none 60 retfie retfie return from interrupt 1 3 (2) none 61 retlw retlw #lit10,wn return with literal in wn 1 3 (2) none 62 return return return from subroutine 1 3 (2) none 63 rlc rlc f f = rotate left through carry f 1 1 c,n,z rlc f,wreg wreg = rotate left through carry f 1 1 c,n,z rlc ws,wd wd = rotate left through carry ws 1 1 c,n,z 64 rlnc rlnc f f = rotate left (no carry) f 1 1 n,z rlnc f,wreg wreg = rotate left (no carry) f 1 1 n,z rlnc ws,wd wd = rotate left (no carry) ws 1 1 n,z 65 rrc rrc f f = rotate right through carry f 1 1 c,n,z rrc f,wreg wreg = rotate right through carry f 1 1 c,n,z rrc ws,wd wd = rotate right through carry ws 1 1 c,n,z 66 rrnc rrnc f f = rotate right (no carry) f 1 1 n,z rrnc f,wreg wreg = rotate right (no carry) f 1 1 n,z rrnc ws,wd wd = rotate right (no carry) ws 1 1 n,z 67 sac sac acc,#slit4,wdo store accumulator 1 1 none sac.r acc,#slit4,wdo store rounded accumulator 1 1 none 68 se se ws,wnd wnd = sign extended ws 1 1 c,n,z 69 setm setm f f = 0xffff 1 1 none setm wreg wreg = 0xffff 1 1 none setm ws ws = 0xffff 1 1 none 70 sftac sftac acc,wn arithmetic shift accumulator by (wn) 1 1 oa,ob,oab, sa,sb,sab sftac acc,#slit6 arithmetic shift accumulator by slit6 1 1 oa,ob,oab, sa,sb,sab 71 sl sl f f = left shift f 1 1 c,n,ov,z sl f,wreg wreg = left shift f 1 1 c,n,ov,z sl ws,wd wd = left shift ws 1 1 c,n,ov,z sl wb,wns,wnd wnd = left shift wb by wns 1 1 n,z sl wb,#lit5,wnd wnd = left shift wb by lit5 1 1 n,z table 19-2: instruction set overview (continued) base instr # assembly mnemonic assembly syntax description # of word s # of cycles status flags affected
dspic30f1010/202x ds70178a-page 220 advance information ? 2006 microchip technology inc. 72 sub sub acc subtract accumulators 1 1 oa,ob,oab, sa,sb,sab sub f f = f ? wreg 1 1 c,dc,n,ov,z sub f,wreg wreg = f ? wreg 1 1 c,dc,n,ov,z sub #lit10,wn wn = wn ? lit10 1 1 c,dc,n,ov,z sub wb,ws,wd wd = wb ? ws 1 1 c,dc,n,ov,z sub wb,#lit5,wd wd = wb ? lit5 1 1 c,dc,n,ov,z 73 subb subb f f = f ? wreg ? (c ) 1 1 c,dc,n,ov,z subb f,wreg wreg = f ? wreg ? (c ) 1 1 c,dc,n,ov,z subb #lit10,wn wn = wn ? lit10 ? (c ) 1 1 c,dc,n,ov,z subb wb,ws,wd wd = wb ? ws ? (c ) 1 1 c,dc,n,ov,z subb wb,#lit5,wd wd = wb ? lit5 ? (c ) 1 1 c,dc,n,ov,z 74 subr subr f f = wreg ? f 1 1 c,dc,n,ov,z subr f,wreg wreg = wreg ? f 1 1 c,dc,n,ov,z subr wb,ws,wd wd = ws ? wb 1 1 c,dc,n,ov,z subr wb,#lit5,wd wd = lit5 ? wb 1 1 c,dc,n,ov,z 75 subbr subbr f f = wreg ? f ? (c ) 1 1 c,dc,n,ov,z subbr f,wreg wreg = wreg ? f ? (c ) 1 1 c,dc,n,ov,z subbr wb,ws,wd wd = ws ? wb ? (c ) 1 1 c,dc,n,ov,z subbr wb,#lit5,wd wd = lit5 ? wb ? (c ) 1 1 c,dc,n,ov,z 76 swap swap.b wn wn = nibble swap wn 1 1 none swap wn wn = byte swap wn 1 1 none 77 tblrdh tblrdh ws,wd read prog<23:16> to wd<7:0> 1 2 none 78 tblrdl tblrdl ws,wd read prog<15:0> to wd 1 2 none 79 tblwth tblwth ws,wd write ws<7:0> to prog<23:16> 1 2 none 80 tblwtl tblwtl ws,wd write ws to prog<15:0> 1 2 none 81 ulnk ulnk unlink frame pointer 1 1 none 82 xor xor f f = f .xor. wreg 1 1 n,z xor f,wreg wreg = f .xor. wreg 1 1 n,z xor #lit10,wn wd = lit10 .xor. wd 1 1 n,z xor wb,ws,wd wd = wb .xor. ws 1 1 n,z xor wb,#lit5,wd wd = wb .xor. lit5 1 1 n,z 83 ze ze ws,wnd wnd = zero-extend ws 1 1 c,z,n table 19-2: instruction set overview (continued) base instr # assembly mnemonic assembly syntax description # of word s # of cycles status flags affected
? 2006 microchip technology inc. advance information ds70178a-page 221 dspic30f1010/202x 20.0 development support the picmicro ? microcontrollers are supported with a full range of hardware and software development tools: ? integrated development environment - mplab ? ide software ? assemblers/compilers/linkers - mpasm tm assembler - mplab c18 and mplab c30 c compilers -mplink tm object linker/ mplib tm object librarian - mplab asm30 assembler/linker/library ? simulators - mplab sim software simulator ?emulators - mplab ice 2000 in-circuit emulator - mplab ice 4000 in-circuit emulator ? in-circuit debugger - mplab icd 2 ? device programmers - picstart ? plus development programmer - mplab pm3 device programmer - pickit? 2 development programmer ? low-cost demonstration and development boards and evaluation kits 20.1 mplab integrated development environment software the mplab ide software brings an ease of software development previously unseen in the 8/16-bit micro- controller market. the mplab ide is a windows ? operating system-based application that contains: ? a single graphical interface to all debugging tools - simulator - programmer (sold separately) - emulator (sold separately) - in-circuit debugger (sold separately) ? a full-featured editor with color-coded context ? a multiple project manager ? customizable data windows with direct edit of contents ? high-level source code debugging ? visual device initializer for easy register initialization ? mouse over variable inspection ? drag and drop variables from source to watch windows ? extensive on-line help ? integration of select third party tools, such as hi-tech software c compilers and iar c compilers the mplab ide allows you to: ? edit your source files (either assembly or c) ? one touch assemble (or compile) and download to picmicro mcu emulator and simulator tools (automatically updates all project information) ? debug using: - source files (assembly or c) - mixed assembly and c - machine code mplab ide supports multiple debugging tools in a single development paradigm, from the cost-effective simulators, through low-cost in-circuit debuggers, to full-featured emulators. this eliminates the learning curve when upgrading to tools with increased flexibility and power.
dspic30f1010/202x ds70178a-page 222 advance information ? 2006 microchip technology inc. 20.2 mpasm assembler the mpasm assembler is a full-featured, universal macro assembler for all picmicro mcus. the mpasm assembler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol reference, absolute lst files that contain source lines and generated machine code and coff files for debugging. the mpasm assembler features include: ? integration into mplab ide projects ? user-defined macros to streamline assembly code ? conditional assembly for multi-purpose source files ? directives that allow complete control over the assembly process 20.3 mplab c18 and mplab c30 c compilers the mplab c18 and mplab c30 code development systems are complete ansi c compilers for microchip?s pic18 family of microcontrollers and the dspic30, dspic33 and pic24 family of digital signal controllers. these compilers provide powerful integra- tion capabilities, superior code optimization and ease of use not found with other compilers. for easy source level debugging, the compilers provide symbol information that is optimized to the mplab ide debugger. 20.4 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler and the mplab c18 c compiler. it can link relocatable objects from precompiled libraries, using directives from a linker script. the mplib object librarian manages the creation and modification of library files of precompiled code. when a routine from a library is called from a source file, only the modules that contain that routine will be linked in with the application. this allows large libraries to be used efficiently in many different applications. the object linker/library features include: ? efficient linking of single libraries instead of many smaller files ? enhanced code maintainability by grouping related modules together ? flexible creation of libraries with easy module listing, replacement, deletion and extraction 20.5 mplab asm30 assembler, linker and librarian mplab asm30 assembler produces relocatable machine code from symbolic assembly language for dspic30f devices. mplab c30 c compiler uses the assembler to produce its object file. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an executable file. notable features of the assembler include: ? support for the entire dspic30f instruction set ? support for fixed-point and floating-point data ? command line interface ? rich directive set ? flexible macro language ? mplab ide compatibility 20.6 mplab sim software simulator the mplab sim software simulator allows code development in a pc-hosted environment by simulat- ing the picmicro mcus and dspic ? dscs on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a comprehensive stimulus controller. registers can be logged to files for further run-time analysis. the trace buffer and logic analyzer display extend the power of the simulator to record and track program execution, actions on i/o, most peripherals and internal registers. the mplab sim software simulator fully supports symbolic debugging using the mplab c18 and mplab c30 c compilers, and the mpasm and mplab asm30 assemblers. the software simulator offers the flexibility to develop and debug code outside of the hardware laboratory environment, making it an excellent, economical software development tool.
? 2006 microchip technology inc. advance information ds70178a-page 223 dspic30f1010/202x 20.7 mplab ice 2000 high-performance in-circuit emulator the mplab ice 2000 in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for picmicro microcontrollers. software control of the mplab ice 2000 in-circuit emulator is advanced by the mplab integrated development environment, which allows editing, building, downloading and source debugging from a single environment. the mplab ice 2000 is a full-featured emulator system with enhanced trace, trigger and data monitor- ing features. interchangeable processor modules allow the system to be easily reconfigured for emulation of different processors. the architecture of the mplab ice 2000 in-circuit emulator allows expansion to support new picmicro microcontrollers. the mplab ice 2000 in-circuit emulator system has been designed as a real-time emulation system with advanced features that are typically found on more expensive development tools. the pc platform and microsoft ? windows ? 32-bit operating system were chosen to best make these features available in a simple, unified application. 20.8 mplab ice 4000 high-performance in-circuit emulator the mplab ice 4000 in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for high-end picmicro mcus and dspic dscs. software control of the mplab ice 4000 in-circuit emulator is provided by the mplab integrated development environment, which allows editing, building, downloading and source debugging from a single environment. the mplab ice 4000 is a premium emulator system, providing the features of mplab ice 2000, but with increased emulation memory and high-speed perfor- mance for dspic30f and pic18xxxx devices. its advanced emulator features include complex triggering and timing, and up to 2 mb of emulation memory. the mplab ice 4000 in-circuit emulator system has been designed as a real-time emulation system with advanced features that are typically found on more expensive development tools. the pc platform and microsoft windows 32-bit operating system were chosen to best make these features available in a simple, unified application. 20.9 mplab icd 2 in-circuit debugger microchip?s in-circuit debugger, mplab icd 2, is a powerful, low-cost, run-time development tool, connecting to the host pc via an rs-232 or high-speed usb interface. this tool is based on the flash picmicro mcus and can be used to develop for these and other picmicro mcus and dspic dscs. the mplab icd 2 utilizes the in-circuit debugging capability built into the flash devices. this feature, along with microchip?s in-circuit serial programming tm (icsp tm ) protocol, offers cost-effective, in-circuit flash debugging from the graphical user interface of the mplab integrated development environment. this enables a designer to develop and debug source code by setting breakpoints, single stepping and watching variables, and cpu status and peripheral registers. running at full speed enables testing hardware and applications in real time. mplab icd 2 also serves as a development programmer for selected picmicro devices. 20.10 mplab pm3 device programmer the mplab pm3 device programmer is a universal, ce compliant device programmer with programmable voltage verification at v ddmin and v ddmax for maximum reliability. it features a large lcd display (128 x 64) for menus and error messages and a modu- lar, detachable socket assembly to support various package types. the icsp? cable assembly is included as a standard item. in stand-alone mode, the mplab pm3 device programmer can read, verify and program picmicro devices without a pc connection. it can also set code protection in this mode. the mplab pm3 connects to the host pc via an rs-232 or usb cable. the mplab pm3 has high-speed communications and optimized algorithms for quick programming of large memory devices and incorporates an sd/mmc card for file storage and secure data applications.
dspic30f1010/202x ds70178a-page 224 advance information ? 2006 microchip technology inc. 20.11 picstart plus development programmer the picstart plus development programmer is an easy-to-use, low-cost, prototype programmer. it connects to the pc via a com (rs-232) port. mplab integrated development environment software makes using the programmer simple and efficient. the picstart plus development programmer supports most picmicro devices in dip packages up to 40 pins. larger pin count devices, such as the pic16c92x and pic17c76x, may be supported with an adapter socket. the picstart plus development programmer is ce compliant. 20.12 pickit 2 development programmer the pickit? 2 development programmer is a low-cost programmer with an easy-to-use interface for pro- gramming many of microchip?s baseline, mid-range and pic18f families of flash memory microcontrollers. the pickit 2 starter kit includes a prototyping develop- ment board, twelve sequential lessons, software and hi-tech?s picc lite c compiler, and is designed to help get up to speed quickly using pic ? micro- controllers. the kit provides everything needed to program, evaluate and develop applications using microchip?s powerful, mid-range flash memory family of microcontrollers. 20.13 demonstration, development and evaluation boards a wide variety of demonstration, development and evaluation boards for various picmicro mcus and dspic dscs allows quick application development on fully func- tional systems. most boards include prototyping areas for adding custom circuitry and provide application firmware and source code for examination and modification. the boards support a variety of features, including leds, temperature sensors, switches, speakers, rs-232 interfaces, lcd displays, potentiometers and additional eeprom memory. the demonstration and development boards can be used in teaching environments, for prototyping custom circuits and for learning about various microcontroller applications. in addition to the picdem? and dspicdem? demon- stration/development board series of circuits, microchip has a line of evaluation kits and demonstration software for analog filter design, k ee l oq ? security ics, can, irda ? , powersmart ? battery management, seeval ? evaluation system, sigma-delta adc, flow rate sensing, plus many more. check the microchip web page (www.microchip.com) and the latest ?product selector guide? (ds00148) for the complete list of demonstration, development and evaluation kits.
? 2006 microchip technology inc. advance information ds70178a-page 225 dspic30f1010/202x 21.0 electrical characteristics this section provides an overview of dspic30f electrical ch aracteristics. additional information will be provided in future revisions of this document as it becomes available. for detailed information about the dspic30f architecture and core, refer to ? dspic30f family reference manual? (ds70046). absolute maximum ratings for the device family are listed below. exposure to these maximum rating conditions for extended periods may affect device reliability. functional operation of the device at these or any other conditions above the parameters indicated in the operation listings of this specification is not implied. absolute maximum ratings (?) ambient temperature under bias................................................................................................. ............-40c to +125c storage temperature ............................................................................................................ .................. -65c to +150c voltage on any pin with respect to v ss (except v dd and mclr ) (1) ................................................ -0.3v to (v dd + 0.3v) voltage on v dd with respect to v ss ......................................................................................................... -0.3v to +5.5v voltage on mclr with respect to v ss (1) ........................................................................................ -0.3v to (v dd + 0.3v) maximum current out of v ss pin ........................................................................................................................... 300 ma maximum current into v dd pin (2) ...........................................................................................................................250 ma input clamp current, i ik (v i < 0 or v i > v dd ) .......................................................................................................... 20 ma output clamp current, i ok (v o < 0 or v o > v dd ) ...................................................................................................20 ma maximum output current sunk by any i/o pin..................................................................................... .....................25 ma maximum output current sourced by any i/o pin .................................................................................. ..................25 ma maximum current sunk by all ports .............................................................................................. .........................200 ma maximum current sourced by all ports (2) ...............................................................................................................200 ma note 1: voltage spikes below v ss at the mclr /v pp pin, inducing currents greater than 80 ma, may cause latch-up. thus, a series resistor of 50-100 should be used when applying a ?low? level to the mclr /v pp pin, rather than pulling this pin directly to v ss . 2: maximum allowable current is a function of device maximum power dissipation. see table 21-2. 21.1 dc characteristics ? notice: stresses above those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. table 21-1: operating mips vs. voltage v dd range temp range max mips dspic30fxxx-30i dspic30fxxx-20i dspic30fxxx-20e 4.5-5.5v -40c to 85c 30 20 ? 4.5-5.5v -40c to 125c ? ? 20 3.0-3.6v -40c to 85c 20 15 ? 3.0-3.6v -40c to 125c ? ? 15
dspic30f1010/202x ds70178a-page 226 advance information ? 2006 microchip technology inc. table 21-2: thermal operating conditions rating symbol min typ max unit dspic30f1010/202x-30i operating junction temperature range t j -40 +125 c operating ambient temperature range t a -40 +85 c dspic30f1010/202x-20i operating junction temperature range t j -40 +150 c operating ambient temperature range t a -40 +85 c dspic30f1010/202x-20e operating junction temperature range t j -40 +150 c operating ambient temperature range t a -40 +125 c power dissipation: internal chip power dissipation: p d p int + p i / o w i/o pin power dissipation: maximum allowed power dissipation p dmax (t j - t a ) / ja w table 21-3: thermal packaging characteristics characteristic symbol typ max unit notes package thermal resistance, 28-pin soic (so) ja 48.3 c/w 1 package thermal resistance, 28-pin qfn ja 33.7 c/w 1 package thermal resistance, 28-pin spdip (sp) ja 42 c/w 1 package thermal resistance, 44-pin qfn ja 28 c/w 1 package thermal resistance, 44-pin tqfp ja 39.3 c/w 1 note 1: junction to ambient thermal resistance, theta-ja ( ja ) numbers are achieved by package simulations. table 21-4: dc temperature and voltage specifications dc characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ (1) max units conditions operating voltage (2) dc10 v dd supply voltage 3.0 ? 5.5 v industrial temperature dc11 v dd supply voltage 4.5 ? 5.5 v extended temperature dc12 v dr ram data retention voltage (3) ?1.5?v dc16 v por v dd start voltage to ensure internal power-on reset signal ?v ss ?v dc17 s vdd v dd rise rate to ensure internal power-on reset signal 0.05 v/ms 0-5v in 0.1 sec 0-3v in 60 ms note 1: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: these parameters are characterized but not tested in manufacturing. 3: this is the limit to which v dd can be lowered without losing ram data. p int v dd i dd i oh ? () = p i / o v dd v oh ? {} i oh () v ol i ol () + =
? 2006 microchip technology inc. advance information ds70178a-page 227 dspic30f1010/202x table 21-5: dc characteristics: operating current (i dd ) dc characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended parameter no. typical (1) max units conditions operating current (i dd ) (2) dc20a 12 ? ma 25c 3.3v frc 4.9 mips dc20b 14 ? ma 85c dc20c ? ? ma 125c dc20e 18 ? ma 25c 5v frc 4.9 mips dc20f 20 ? ma 85c dc20g ? ? ma 125c dc23a 45 ? ma 25c 3.3v 20 mips, 32x pll dc23b 48 81 ma 85c dc23c ? ? ma 125c dc23e 100 ? ma 25c 5v 30 mips, 32x pll dc23f 104 212 ma 85c dc23g ? ? ma 125c dc30a 18 ? ma 25c 3.3v frc 7.3 mips dc30b 20 ? ma 85c dc30c ? ? ma 125c dc30e 22 ? ma 25c 5v frc 7.3 mips dc30f 24 ? ma 85c dc30g ? ? ma 125c dc31a 45 ? ma 25c 3.3v frc 20 mips, 32x pll dc31b 48 81 ma 85c dc31c ? ? ma 125c dc31e 100 ? ma 25c 5v frc 30 mips, 32x pll dc31f 104 212 ma 85c dc31g ? ? ma 125c note 1: data in ?typical? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: the supply current is mainly a function of the operating voltage and frequency. other factors such as i/o pin loading and switching rate, oscillator type, internal code execution pattern and temperature also have an impact on the current consumption. the test conditions for all i dd measurements are as follows: osc1 driven with external square wave from rail to rail. all i/o pins are configured as inputs and pulled to v dd . mclr = v dd , wdt and fscm are disabled. cpu, sram, program memory and data memory are operational. no peripheral modules are operating.
dspic30f1010/202x ds70178a-page 228 advance information ? 2006 microchip technology inc. table 21-6: dc characteristics: idle current (i idle ) dc characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended parameter no. typical (1) max units conditions idle current (i idle ): core off clock on base current (2) dc40a 9 ? ma 25c 3.3v frc 4.9 mips dc40b ? ? ma 85c dc40c ? ? ma 125c dc40e 16 ? ma 25c 5v frc 4.9 mipse dc40f ? ? ma 85c dc40g ? ? ma 125c dc43a 23 ? ma 25c 3.3v 20 mips, 32x pll dc43b ? 46 ma 85c dc43c ? ? ma 125c dc43e 58 ? ma 25c 5v 30 mips, 32x pll dc43f ? 47 ma 85c dc43g ? ? ma 125c dc50a 13 ? ma 25c 3.3v frc 7.3 mips dc50b ? ? ma 85c dc50c ? ? ma 125c dc50e 18 ? ma 25c 5v frc 7.3 mips dc50f ? ? ma 85c dc50g ? ? ma 125c dc51a 23 ? ma 25c 3.3v frc 20 mips, 32x pll dc51b ? 46 ma 85c dc51c ? ? ma 125c dc51e 58 ? ma 25c 5v frc 30 mips, 32x pll dc51f ? 87 ma 85c dc51g ? ? ma 125c note 1: data in ?typical? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: base i idle current is measured with core off, clock on and all modules turned off.
? 2006 microchip technology inc. advance information ds70178a-page 229 dspic30f1010/202x table 21-7: dc characteristics: power-down current (i pd ) dc characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended parameter no. typical (1) max units conditions power-down current (i pd ) (2) dc60a 3 ? a 25c 3.3v base power-down current (3) dc60b 5 ? a 85c dc60c 8 ? a 125c dc60e 4 ? a 25c 5v dc60f 7 ? a 85c dc60g 14 ? a 125c dc61a 18 ? a 25c 3.3v watchdog timer current: i wdt (3) dc61b ? ? a 85c dc61c ? ? a 125c dc61e 35 ? a 25c 5v dc61f ? ? a 85c dc61g ? ? a 125c note 1: data in the typical column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: base i pd is measured with all peripherals and clocks shutdown. all i/os are configured as inputs and pulled high. wdt, etc. are all switched off. 3: the current is the additional current consumed when the module is enabled. this current should be added to the base i pd current.
dspic30f1010/202x ds70178a-page 230 advance information ? 2006 microchip technology inc. table 21-8: dc characteristics: i/o pin input specifications dc characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ (1) max units conditions v il input low voltage (2) di10 i/o pins: with schmitt trigger buffer v ss ?0.2v dd v di15 mclr v ss ?0.2v dd v di16 osc1 (in xt, hs and lp modes) v ss ?0.2v dd v di17 osc1 (in rc mode) (3) v ss ?0.3v dd v di18 sda, scl v ss ?0.3v dd v sm bus disabled di19 sda, scl v ss ?0.2v dd v sm bus enabled v ih input high voltage (2) di20 i/o pins: with schmitt trigger buffer 0.8 v dd ?v dd v di25 mclr 0.8 v dd ?v dd v di26 osc1 (in xt, hs and lp modes) 0.7 v dd ?v dd v di27 osc1 (in rc mode) (3) 0.9 v dd ?v dd v di28 sda, scl 0.7 v dd ?v dd v sm bus disabled di29 sda, scl 0.8 v dd ?v dd v sm bus enabled i il input leakage current (2)(4)(5) di50 i/o ports ? 0.01 1 av ss v pin v dd , pin at high-impedance di51 analog input pins ? 0.50 ? av ss v pin v dd , pin at high-impedance di55 mclr ?0.055 av ss v pin v dd di56 osc1 ? 0.05 5 av ss v pin v dd , xt, hs and lp osc mode note 1: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: these parameters are characterized but not tested in manufacturing. 3: in rc oscillator configuration, the osc1/clk1 pin is a schmitt trigger input. it is not recommended that the dspic30f device be driven with an external clock while in rc mode. 4: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 5: negative current is defined as current sourced by the pin.
? 2006 microchip technology inc. advance information ds70178a-page 231 dspic30f1010/202x table 21-10: dc characteristics: program and eeprom table 21-9: dc characteristics: i/o pin output specifications dc characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ (1) max units conditions v ol output low voltage (2) do10 i/o ports ? ? 0.6 v i ol = 8.5 ma, v dd = 5v ??tbdvi ol = 2.0 ma, v dd = 3v do16 osc2/clkout ? ? 0.6 v i ol = 1.6 ma, v dd = 5v (rc or ec osc mode) ? ? tbd v i ol = 2.0 ma, v dd = 3v v oh output high voltage (2) do20 i/o ports v dd ? 0.7 ? ? v i oh = -3.0 ma, v dd = 5v tbd ? ? v i oh = -2.0 ma, v dd = 3v do26 osc2/clkout v dd ? 0.7 ? ? v i oh = -1.3 ma, v dd = 5v (rc or ec osc mode) tbd ? ? v i oh = -2.0 ma, v dd = 3v capacitive loading specs on output pins (2) do50 c osc 2 osc2 pin ? ? 15 pf in xtl, xt, hs and lp modes when external clock is used to drive osc1. do56 c io all i/o pins and osc2 ? ? 50 pf rc or ec osc mode do58 c b scl, sda ? ? 400 pf in i 2 c mode legend: tbd = to be determined note 1: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: these parameters are characterized but not tested in manufacturing. dc characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ (1) max units conditions program flash memory (2) d130 e p cell endurance 10k 100k ? e/w -40 c t a +85c d131 v pr v dd for read v min ?5.5vv min = minimum operating voltage d132 v eb v dd for bulk erase 4.5 ? 5.5 v d133 v pew v dd for erase/write 3.0 ? 5.5 v d134 t pew erase/write cycle time ? 2 ? ms d135 t retd characteristic retention 40 100 ? year provided no other specifications are violated d136 t eb icsp block erase time ? 4 ? ms d137 i pew i dd during programming ? 10 30 ma row erase d138 i eb i dd during programming ? 10 30 ma bulk erase note 1: data in ?typ? column is at 5v, 25c unless otherwise stated. 2: these parameters are characterized but not tested in manufacturing.
dspic30f1010/202x ds70178a-page 232 advance information ? 2006 microchip technology inc. 21.2 ac characteristics and timing parameters the information contained in this section defines dspic30f ac characteristics and timing parameters. table 21-11: temperature and voltage specifications ? ac figure 21-1: load conditions for device timing specifications figure 21-2: external clock timing ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended operating voltage v dd range as described in dc spec section 21.0. v dd /2 c l r l pin pin v ss v ss c l r l = 464 c l = 50 pf for all pins except osc2 5 pf for osc2 output load condition 1 ? for all pins except osc2 load condition 2 ? for osc2 osc1 clkout q4 q1 q2 q3 q4 q1 os20 os25 os30 os30 os40 os41 os31 os31
? 2006 microchip technology inc. advance information ds70178a-page 233 dspic30f1010/202x table 21-12: external clock timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ (1) max units conditions os10 f osc external clki frequency (2) (external clocks allowed only in ec mode) 9.55 9.55 ? ? 15.00 15.00 mhz mhz ec ec with 32x pll oscillator frequency (2) 9.55 9.55 ? ? 15.00 15.00 mhz mhz hs frc internal os20 t osc t osc = 1/f osc ? ? ? ? see parameter os10 for f osc value os25 t cy instruction cycle time (2)(3) 33 ? dc ns os30 tosl, tos h external clock (2) in (osc1) high or low time .45 x t osc ??nsec os31 tosr, tos f external clock (2) in (osc1) rise or fall time ? ? 20 ns ec os40 tckr clkout rise time (2)(4) ? 6 10 ns os41 tckf clkout fall time (2)(4) ? 6 10 ns note 1: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: these parameters are characterized but not tested in manufacturing. 3: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. all devices are tested to operate at ?min.? values with an external clock applied to the osc1/clk1 pin. when an external clock input is used, the ?max.? cycle time limit is ?dc? (no clock) for all devices. 4: measurements are taken in ec or erc modes. the clkout signal is measured on the osc2 pin. clkout is low for the q1-q2 period (1/2 t cy ) and high for the q3-q4 period (1/2 t cy ).
dspic30f1010/202x ds70178a-page 234 advance information ? 2006 microchip technology inc. table 21-14: internal clo ck timing examples table 21-13: pll clock ti ming specifications (v dd = 3.0 and 5.0v ) ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions os50 f plli pll input frequency range (2) 9.55 ? 15 mhz ec, hs modes with pll x32 os51 f sys on-chip pll output (2) 305 ? 480 mhz ec, hs modes with pll x32 os52 t loc pll start-up time (lock time) ? 20 50 s os53 d clk clkout stability (jitter) tbd 1 tbd % measured over 100 ms period legend: tbd = to be determined note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. clock oscillator mode f osc (mhz) (1) t cy ( sec) (2) mips (3) w/o pll mips (4) w/pll x32 ec 10 0.2 5.0 20 15 0.133 7.5 30 hs 10 0.2 5.0 20 15 0.133 7.5 30 note 1: assumption: oscillator postscaler is divide by 1. 2: instruction execution cycle time: t cy = 1 / mips. 3: instruction execution frequency without pll: mips = f osc / 2 (since there are 2 q clocks per instruction cycle). 4: instruction execution frequency with pll: mips = (f osc * 2).
? 2006 microchip technology inc. advance information ds70178a-page 235 dspic30f1010/202x table 21-15: ac characteristics: internal rc accuracy ac characteristics standard operating conditions: 3.3v and 5.0v ( 10%) (unless otherwise stated) operating temperature -40c ta +85c for industrial -40c ta +125c for extended param no. characteristic min typ max units conditions internal frc accuracy @ frc freq = 9.7 mhz (1) frc tbd % +25c v dd = 3.0-3.6v tbd % +25c v dd = 4.5-5.5v tbd % -40c t a +85c v dd = 3.0-3.6v tbd % -40c t a +85c v dd = 4.5-5.5v tbd % -40c t a +125c v dd = 4.5-5.5v internal frc accuracy @ frc freq = 14.55 mhz (1) frc tbd % +25c v dd = 3.0-3.6v tbd % +25c v dd = 4.5-5.5v tbd % -40c t a +85c v dd = 3.0-3.6v tbd % -40c t a +85c v dd = 4.5-5.5v tbd % -40c t a +125c v dd = 4.5-5.5v legend: tbd = to be determined note 1: frequency calibrated at 25c and 5v. tun bits can be used to compensate for temperature drift. table 21-16: ac characteristics: internal rc jitter ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c ta +85c for industrial -40c ta +125c for extended param no. characteristic min typ max units conditions internal frc jitter @ frc freq = 9.7 mhz (1) frc tbd % +25c v dd = 3.0-3.6v tbd % +25c v dd = 4.5-5.5v tbd % -40c t a +85c v dd = 3.0-3.6v tbd % -40c t a +85c v dd = 4.5-5.5v tbd % -40c t a +125c v dd = 4.5-5.5v internal frc jitter @ frc freq = 14.55 mhz (1) frc tbd % +25c v dd = 3.0-3.6v tbd % +25c v dd = 4.5-5.5v tbd % -40c t a +85c v dd = 3.0-3.6v tbd % -40c t a +85c v dd = 4.5-5.5v tbd % -40c t a +125c v dd = 4.5-5.5v legend: tbd = to be determined note 1: frequency calibrated at 25c and 5v. tun bits can be used to compensate for temperature drift.
dspic30f1010/202x ds70178a-page 236 advance information ? 2006 microchip technology inc. figure 21-3: clkout and i/o timing characteristics table 21-17: clkout and i/o timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1)(2)(3) min typ (4) max units conditions do31 t io r port output rise time ? 10 25 ns ? do32 t io f port output fall time ? 10 25 ns ? di35 t inp intx pin high or low time (output) 20 ? ? ns ? di40 t rbp cnx high or low time (input) 2 t cy ??ns ? note 1: these parameters are asynchronous events not related to any internal clock edges 2: measurements are taken in rc mode and ec mode where clkout output is 4 x t osc . 3: these parameters are characterized but not tested in manufacturing. 4: data in ?typ? column is at 5v, 25c unless otherwise stated. note: refer to figure 21-1 for load conditions. i/o pin (input) i/o pin (output) di35 old value new value di40 do31 do32
? 2006 microchip technology inc. advance information ds70178a-page 237 dspic30f1010/202x figure 21-4: reset, watchdog timer, oscillator start-up timer and power-up timer timing characteristics v dd mclr internal por pwrt time-out osc time-out internal reset watchdog timer reset sy11 sy10 sy20 sy13 i/o pins sy13 note: refer to figure 21-1 for load conditions. fscm delay sy35 sy30 sy12
dspic30f1010/202x ds70178a-page 238 advance information ? 2006 microchip technology inc. table 21-18: reset, watchdog timer, oscillator start-up timer, power-up timer and timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions sy10 tmcl mclr pulse width (low) 2 ? ? s -40c to +85c sy11 t pwrt power-up timer period tbd tbd tbd tbd 0 4 16 64 tbd tbd tbd tbd ms -40c to +85c user programmable sy12 t por power-on reset delay 3 10 30 s -40c to +85c sy13 t ioz i/o high-impedance from mclr low or watchdog timer reset ?0.81.0 s sy20 t wdt 1 watchdog timer time-out period (no prescaler) 1.6 2.2 3.0 ms v dd = 5v, -40c to +85c t wdt 2 1.7 2.2 3.1 ms v dd = 3v, -40c to +85c sy30 t ost oscillation start-up timer period ? 1024 t osc ??t osc = osc1 period sy35 t fscm fail-safe clock monitor delay ? 500 ? s -40c to +85c legend: tbd = to be determined note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated.
? 2006 microchip technology inc. advance information ds70178a-page 239 dspic30f1010/202x figure 21-5: band gap start-up time characteristics table 21-19: band gap start-up time requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions sy40 t bgap band gap start-up time ? 40 65 s defined as the time between the instant that the band gap is enabled and the moment that the band gap reference voltage is stable. rcon<13> status bit. note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. v bgap enable band gap band gap 0v (see note) stable note: band gap is enabled when fborpor<7> is set. sy40
dspic30f1010/202x ds70178a-page 240 advance information ? 2006 microchip technology inc. figure 21-6: timer external clock timing characteristics table 21-20: timer1 external clock timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ max units conditions ta10 t tx h txck high time synchronous, no prescaler 0.5 t cy + 20 ? ? ns must also meet parameter ta15 synchronous, with prescaler 10 ? ? ns asynchronous 10 ? ? ns ta11 t tx l txck low time synchronous, no prescaler 0.5 t cy + 20 ? ? ns must also meet parameter ta15 synchronous, with prescaler 10 ? ? ns asynchronous 10 ? ? ns ta15 t tx p txck input period synchronous, no prescaler t cy + 10 ? ? ns synchronous, with prescaler greater of: 20 ns or (t cy + 40)/n ? ? ? n = prescale value (1, 8, 64, 256) asynchronous 20 ? ? ns os60 ft1 sosc1/t1ck oscillator input frequency range (oscillator enabled by setting bit tcs (t1con, bit 1)) dc ? 50 khz ta20 t ckextmrl delay from external txck clock edge to timer increment 0.5 t cy 1.5 t cy ? tx11 tx15 tx10 tx20 tmrx os60 txck note: ?x? refers to timer type a or timer type b. refer to figure 21-1 for load conditions.
? 2006 microchip technology inc. advance information ds70178a-page 241 dspic30f1010/202x table 21-21: timer2 external clock timing requirements table 21-22: timer3 external clock timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ max units conditions tb10 ttxh txck high time synchronous, no prescaler 0.5 t cy + 20 ? ? ns must also meet parameter tb15 synchronous, with prescaler 10 ? ? ns tb11 ttxl txck low time synchronous, no prescaler 0.5 t cy + 20 ? ? ns must also meet parameter tb15 synchronous, with prescaler 10 ? ? ns tb15 ttxp txck input period synchronous, no prescaler t cy + 10 ? ? ns n = prescale value (1, 8, 64, 256) synchronous, with prescaler greater of: 20 ns or (t cy + 40) / n tb20 t ckextmrl delay from external txck clock edge to timer increment 0.5 t cy ? 1.5 t cy ? ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min typ max units conditions tc10 ttxh txck high time synchronous 0.5 t cy + 20 ? ? ns must also meet parameter tc15 tc11 ttxl txck low time synchronous 0.5 t cy + 20 ? ? ns must also meet parameter tc15 tc15 ttxp txck input period synchronous, no prescaler t cy + 10 ? ? ns n = prescale value (1, 8, 64, 256) synchronous, with prescaler greater of: 20 ns or (t cy + 40) / n tc20 t ckextmrl delay from external txck clock edge to timer increment 0.5 t cy ? 1.5 t cy ?
dspic30f1010/202x ds70178a-page 242 advance information ? 2006 microchip technology inc. figure 21-7: input capture (capx) timing characteristics table 21-23: input capture timing requirements figure 21-8: output compare module (ocx) timing characteristics table 21-24: output compare module timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min max units conditions ic10 tccl icx input low time no prescaler 0.5 t cy + 20 ? ns with prescaler 10 ? ns ic11 tcch icx input high time no prescaler 0.5 t cy + 20 ? ns with prescaler 10 ? ns ic15 tccp icx input period (2 t cy + 40) / n ? ns n = prescale value (1, 4, 16) note 1: these parameters are characterized but not tested in manufacturing. ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions oc10 tccf ocx output fall time ? ? ? ns see parameter d032 oc11 tccr ocx output rise time ? ? ? ns see parameter d031 note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. ic x ic10 ic11 ic15 note: refer to figure 21-1 for load conditions. ocx oc11 oc10 (output compare note: refer to figure 21-1 for load conditions. or pwm mode)
? 2006 microchip technology inc. advance information ds70178a-page 243 dspic30f1010/202x figure 21-9: oc/pwm module timing characteristics table 21-25: simple oc/pwm mode timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions oc15 t fd fault input to pwm i/o change ??25nsv dd = 3v -40c to +85c tbd ns v dd = 5v oc20 t flt fault input pulse width ? ? 50 ns v dd = 3v -40c to +85c tbd ns v dd = 5v legend: tbd = to be determined note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. ocfa/ocfb ocx oc20 oc15
dspic30f1010/202x ds70178a-page 244 advance information ? 2006 microchip technology inc. figure 21-10: smps pwm module fault timing characteristics figure 21-11: motor control pwm module timing characteristics table 21-26: motor control pw m module timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions mp10 t f pwm pwm output fall time ? 10 25 ns v dd = 5v -40c to +85c mp11 t r pwm pwm output rise time ? 10 25 ns v dd = 5v -40c to +85c mp12 t f pwm pwm output fall time ? tbd tbd ns v dd = 3v -40c to +85c mp13 t r pwm pwm output rise time ? tbd tbd ns v dd = 3v -40c to +85c mp20 t fd fault input to pwm i/o change ? ? 25 ns v dd = 3v -40c to +85c tbd ns v dd = 5v mp30 t fh minimum pulse width ? ? 50 ns v dd = 3v -40c to +85c tbd ns v dd = 5v legend: tbd = to be determined note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. flta/b pwmx mp30 mp20 pwmx mp11 mp10 note: refer to figure 21-1 for load conditions.
? 2006 microchip technology inc. advance information ds70178a-page 245 dspic30f1010/202x figure 21-12: spi module master mode (cke = 0 ) timing characteristics table 21-27: spi master mode (cke = 0 ) timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended para m no. symbol characteristic (1) min typ (2) max units conditions sp10 tscl sck x output low time (3) t cy / 2 ? ? ns ? sp11 tsch sck x output high time (3) t cy / 2 ? ? ns ? sp20 tscf sck x output fall time (4) ? ? ? ns see parameter d032 sp21 tscr sck x output rise time (4) ? ? ? ns see parameter d031 sp30 tdof sdo x data output fall time (4) ? ? ? ns see parameter d032 sp31 tdor sdo x data output rise time (4) ? ? ? ns see parameter d031 sp35 tsch2dov, tscl2dov sdo x data output valid after sck x edge ? ? 30 ns ? sp40 tdiv2sch, tdiv2scl setup time of sdi x data input to sck x edge 20 ? ? ns ? sp41 tsch2dil, tscl2dil hold time of sdi x data input to sck x edge 20 ? ? ns ? note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 3: the minimum clock period for sck is 100 ns. therefore, the clock generated in master mode must not violate this specification. 4: assumes 50 pf load on all spi pins. sckx (ckp = 0 ) sckx (ckp = 1 ) sdox sdix sp11 sp10 sp40 sp41 sp21 sp20 sp35 sp20 sp21 msb lsb bit14 - - - - - -1 msb in lsb in bit14 - - - -1 sp30 sp31 note: refer to figure 21-1 for load conditions.
dspic30f1010/202x ds70178a-page 246 advance information ? 2006 microchip technology inc. figure 21-13: spi module master mode (cke = 1 ) timing characteristics table 21-28: spi module master mode (cke = 1 ) timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions sp10 tscl sck x output low time (3) t cy / 2 ? ? ns ? sp11 tsch sck x output high time (3) t cy / 2 ? ? ns ? sp20 tscf sck x output fall time (4) ? ? ? ns see parameter d032 sp21 tscr sck x output rise time (4) ? ? ? ns see parameter d031 sp30 tdof sdo x data output fall time (4) ? ? ? ns see parameter d032 sp31 tdor sdo x data output rise time (4) ? ? ? ns see parameter d031 sp35 tsch2dov, tscl2dov sdo x data output valid after sck x edge ??30 ns ? sp36 tdov2sc, tdov2scl sdo x data output setup to first sck x edge 30 ? ? ns ? sp40 tdiv2sch, tdiv2scl setup time of sdi x data input to sck x edge 20 ? ? ns ? sp41 tsch2dil, tscl2dil hold time of sdi x data input to sck x edge 20 ? ? ns ? note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 3: the minimum clock period for sck is 100 ns. therefore, the clock generated in master mode must not violate this specification. 4: assumes 50 pf load on all spi pins. sck x (ckp = 0 ) sck x (ckp = 1 ) sdo x sdi x sp36 sp30,sp31 sp35 msb msb in bit14 - - - - - -1 lsb in bit14 - - - -1 lsb note: refer to figure 21-1 for load conditions. sp11 sp10 sp20 sp21 sp21 sp20 sp40 sp41
? 2006 microchip technology inc. advance information ds70178a-page 247 dspic30f1010/202x figure 21-14: spi module slave mode (cke = 0 ) timing characteristics table 21-29: spi module slave mode (cke = 0 ) timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions sp70 tscl sck x input low time 30 ? ? ns ? sp71 tsch sck x input high time 30 ? ? ns ? sp72 tscf sck x input fall time (3) ?1025 ns ? sp73 tscr sck x input rise time (3) ?1025 ns ? sp30 tdof sdo x data output fall time (3) ? ? ? ns see parameter d032 sp31 tdor sdo x data output rise time (3) ? ? ? ns see parameter d031 sp35 tsch2dov, tscl2dov sdo x data output valid after sck x edge ? ? 30 ns ? sp40 tdiv2sch, tdiv2scl setup time of sdi x data input to sck x edge 20 ? ? ns ? sp41 tsch2dil, ts c l 2 d i l hold time of sdi x data input to sck x edge 20 ? ? ns ? sp50 tssl2sch, ts s l 2 s c l ss x to sck x or sck x input 120 ? ? ns ? sp51 tssh2doz ss x to sdo x output high-impedance (3) 10 ? 50 ns ? sp52 tsch2ssh tsc l2 s sh ss x after sck edge 1.5 t cy + 40 ?? ns ? note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 3: assumes 50 pf load on all spi pins. ss x sck x (ckp = 0 ) sck x (ckp = 1 ) sdo x sdi sp50 sp40 sp41 sp30,sp31 sp51 sp35 sdi x msb lsb bit14 - - - - - -1 msb in bit14 - - - -1 lsb in sp52 sp73 sp72 sp72 sp73 sp71 sp70 note: refer to figure 21-1 for load conditions.
dspic30f1010/202x ds70178a-page 248 advance information ? 2006 microchip technology inc. figure 21-15: spi module slave mode (cke = 1 ) timing characteristics ss x sck x (ckp = 0 ) sck x (ckp = 1 ) sdo x sdi sp50 sp60 sdi x sp30,sp31 msb bit14 - - - - - -1 lsb sp51 msb in bit14 - - - -1 lsb in sp35 sp52 sp52 sp73 sp72 sp72 sp73 sp71 sp70 sp40 sp41 note: refer to figure 21-1 for load conditions.
? 2006 microchip technology inc. advance information ds70178a-page 249 dspic30f1010/202x table 21-30: spi module slave mode (cke = 1 ) timing requirements ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic (1) min typ (2) max units conditions sp70 tsc l sck x input low time 30 ? ? ns ? sp71 tsch sck x input high time 30 ? ? ns ? sp72 tscf sck x input fall time (3) ?1025ns ? sp73 tscr sck x input rise time (3) ?1025ns ? sp30 tdof sdo x data output fall time (3) ? ? ? ns see parameter d032 sp31 tdor sdo x data output rise time (3) ? ? ? ns see parameter d031 sp35 tsch2dov, tscl2dov sdo x data output valid after sck x edge ??30ns ? sp40 tdiv2sch, tdiv2scl setup time of sdi x data input to sck x edge 20 ? ? ns ? sp41 tsch2dil, tscl2dil hold time of sdi x data input to sck x edge 20 ? ? ns ? sp50 tssl2sch, tssl2scl ss x to sck x or sck x input 120 ? ? ns ? sp51 tssh2doz ss to sdo x output high-impedance (4) 10 ? 50 ns ? sp52 tsch2ssh tscl2ssh ss x after sck x edge 1.5 t cy + 40 ??ns ? sp60 tssl2dov sdo x data output valid after ss x edge ??50ns ? note 1: these parameters are characterized but not tested in manufacturing. 2: data in ?typ? column is at 5v, 25c unless otherwise stated. parameters are for design guidance only and are not tested. 3: the minimum clock period for sck is 100 ns. therefore, the clock generated in master mode must not violate this specification. 4: assumes 50 pf load on all spi pins.
dspic30f1010/202x ds70178a-page 250 advance information ? 2006 microchip technology inc. figure 21-16: i 2 c? bus start/stop bits timing characteristics (master mode) figure 21-17: i 2 c? bus data timing characteristics (master mode) im31 im34 scl sda start condition stop condition im30 im33 note: refer to figure 21-1 for load conditions. im11 im10 im33 im11 im10 im20 im26 im25 im40 im40 im45 im21 scl sda in sda out note: refer to figure 21-1 for load conditions.
? 2006 microchip technology inc. advance information ds70178a-page 251 dspic30f1010/202x table 21-31: i 2 c? bus data timing requirements (master mode) ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min (1) max units conditions im10 t lo : scl clock low time 100 khz mode t cy / 2 (brg + 1) ? s ? 400 khz mode t cy / 2 (brg + 1) ? s ? 1 mhz mode (2) t cy / 2 (brg + 1) ? s ? im11 t hi : scl clock high time 100 khz mode t cy / 2 (brg + 1) ? s ? 400 khz mode t cy / 2 (brg + 1) ? s ? 1 mhz mode (2) t cy / 2 (brg + 1) ? s ? im20 t f : scl sda and scl fall time 100 khz mode ? 300 ns c b is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1 c b 300 ns 1 mhz mode (2) ? 100 ns im21 t r : scl sda and scl rise time 100 khz mode ? 1000 ns c b is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1 c b 300 ns 1 mhz mode (2) ? 300 ns im25 t su : dat data input setup time 100 khz mode 250 ? ns ? 400 khz mode 100 ? ns 1 mhz mode (2) tbd ? ns im26 t hd : dat data input hold time 100 khz mode 0 ? ns ? 400 khz mode 0 0.9 s 1 mhz mode (2) tbd ? ns im30 t su : sta start condition setup time 100 khz mode t cy / 2 (brg + 1) ? s only relevant for repeated start condition 400 khz mode t cy / 2 (brg + 1) ? s 1 mhz mode (2) t cy / 2 (brg + 1) ? s im31 t hd : sta start condition hold time 100 khz mode t cy / 2 (brg + 1) ? s after this period the first clock pulse is generated 400 khz mode t cy / 2 (brg + 1) ? s 1 mhz mode (2) t cy / 2 (brg + 1) ? s im33 t su : sto stop condition setup time 100 khz mode t cy / 2 (brg + 1) ? s ? 400 khz mode t cy / 2 (brg + 1) ? s 1 mhz mode (2) t cy / 2 (brg + 1) ? s im34 t hd : sto stop condition 100 khz mode t cy / 2 (brg + 1) ? ns ? hold time 400 khz mode t cy / 2 (brg + 1) ? ns 1 mhz mode (2) t cy / 2 (brg + 1) ? ns im40 t aa : scl output valid from clock 100 khz mode ? 3500 ns ? 400 khz mode ? 1000 ns ? 1 mhz mode (2) ??ns ? im45 t bf : sda bus free time 100 khz mode 4.7 ? s time the bus must be free before a new transmission can start 400 khz mode 1.3 ? s 1 mhz mode (2) tbd ? s im50 c b bus capacitive loading ? 400 pf legend: tbd = to be determined note 1: brg is the value of the i 2 c? baud rate generator. refer to section 21 ?inter-integrated circuit? (i 2 c)? in the ?dspic30f family reference manual? (ds70046) . 2: maximum pin capacitance = 10 pf for all i 2 c pins (for 1 mhz mode only).
dspic30f1010/202x ds70178a-page 252 advance information ? 2006 microchip technology inc. figure 21-18: i 2 c? bus start/stop bits timing characteristics (slave mode) figure 21-19: i 2 c? bus data timing characteristics (slave mode) is31 is34 scl sda start condition stop condition is30 is33 is30 is31 is33 is11 is10 is20 is26 is25 is40 is40 is45 is21 scl sda in sda out
? 2006 microchip technology inc. advance information ds70178a-page 253 dspic30f1010/202x table 21-32: i 2 c? bus data timing requirements (slave mode) ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min max units conditions is10 t lo : scl clock low time 100 khz mode 4.7 ? s device must operate at a minimum of 1.5 mhz 400 khz mode 1.3 ? s device must operate at a minimum of 10 mhz. 1 mhz mode (1) 0.5 ? s? is11 t hi : scl clock high time 100 khz mode 4.0 ? s device must operate at a minimum of 1.5 mhz 400 khz mode 0.6 ? s device must operate at a minimum of 10 mhz 1 mhz mode (1) 0.5 ? s? is20 t f : scl sda and scl fall time 100 khz mode ? 300 ns c b is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1 c b 300 ns 1 mhz mode (1) ? 100 ns is21 t r : scl sda and scl rise time 100 khz mode ? 1000 ns c b is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1 c b 300 ns 1 mhz mode (1) ? 300 ns is25 t su : dat data input setup time 100 khz mode 250 ? ns ? 400 khz mode 100 ? ns 1 mhz mode (1) 100 ? ns is26 t hd : dat data input hold time 100 khz mode 0 ? ns ? 400 khz mode 0 0.9 s 1 mhz mode (1) 00.3 s is30 t su : sta start condition setup time 100 khz mode 4.7 ? s only relevant for repeated start condition 400 khz mode 0.6 ? s 1 mhz mode (1) 0.25 ? s is31 t hd : sta start condition hold time 100 khz mode 4.0 ? s after this period the first clock pulse is generated 400 khz mode 0.6 ? s 1 mhz mode (1) 0.25 ? s is33 t su : sto stop condition setup time 100 khz mode 4.7 ? s? 400 khz mode 0.6 ? s 1 mhz mode (1) 0.6 ? s is34 t hd : sto stop condition 100 khz mode 4000 ? ns ? hold time 400 khz mode 600 ? ns 1 mhz mode (1) 250 ns is40 t aa : scl output valid from clock 100 khz mode 0 3500 ns ? 400 khz mode 0 1000 ns 1 mhz mode (1) 0 350 ns is45 t bf : sda bus free time 100 khz mode 4.7 ? s time the bus must be free before a new transmission can start 400 khz mode 1.3 ? s 1 mhz mode (1) 0.5 ? s is50 c b bus capacitive loading ? 400pf ? note 1: maximum pin capacitance = 10 pf for all i 2 c? pins (for 1 mhz mode only).
dspic30f1010/202x ds70178a-page 254 advance information ? 2006 microchip technology inc. table 21-33: 10-bit high-speed a/d module specifications ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min. typ max. units conditions device supply ad01 av dd module v dd supply greater of v dd ? 0.3 or 2.7 lesser of v dd + 0.3 or 5.5 v? ad02 av ss module v ss supply vss ? 0.3 v ss + 0.3 v ? reference inputs ad05 v refh reference voltage high avss + 2.7 av dd v? ad06 v refl reference voltage low avss av dd ? 2.7 v ? ad07 v ref absolute reference voltage avss ? 0.3 av dd + 0.3 v ? ad08 i ref current drain ? 200 .001 300 3 a a a/d operating a/d off analog input ad10 v inh -v inl full-scale input span v refl v refh v? ad11 v in absolute input voltage av ss ? 0.3 av dd + 0.3 v ? ad12 ? leakage current ? 0.001 0.244 av inl = av ss = v refl = 0v, av dd = v refh = 5v source impedance = 5 k ad13 ? leakage current ? 0.001 0.244 av inl = av ss = v refl = 0v, av dd = v refh = 3v source impedance = 5 k ad15 r ss switch resistance ? 3.2k ? ? ad16 c sample sample capacitor ? 4.4 pf ? ad17 r in recommended impedance of analog voltage source ?5k ? dc accuracy ad20 nr resolution 10 data bits bits ? ad21 inl integral nonlinearity ? 0.5 < 1 lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad21a inl integral nonlinearity ? 0.5 < 1 lsb v inl = av ss = v refl = 0v, av dd = v refh = 3v ad22 dnl differential nonlinearity ? 0.5 < 1 lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad22a dnl differential nonlinearity ? 0.5 < 1 lsb v inl = av ss = v refl = 0v, av dd = v refh = 3v ad23 g err gain error ? 0.75 tbd lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad23a g err gain error ? 0.75 tbd lsb v inl = av ss = v refl = 0v, av dd = v refh = 3v legend: tbd = to be determined note 1: because the sample caps will eventually lose charge, clock rates below 10 khz can affect linearity performance, especially at elevated temperatures. 2: the a/d conversion result never decreases with an increase in the input voltage, and has no missing codes.
? 2006 microchip technology inc. advance information ds70178a-page 255 dspic30f1010/202x figure 21-20: a/d conversion timing per input ad24 e off offset error ? 0.75 tbd lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad24a e off offset error ? 0.75 tbd lsb v inl = av ss = v refl = 0v, av dd = v refh = 3v ad25 ? monotonicity (2) ? ? ? ? guaranteed dynamic performance ad30 thd total harmonic distortion ? tbd ? db ? ad31 sinad signal to noise and distortion ?tbd ? db ? ad32 sfdr spurious free dynamic range ?tbd ? db ? ad33 f nyq input signal bandwidth ? ? 1 mhz ? ad34 enob effective number of bits ? tbd tbd bits ? table 21-33: 10-bit high-speed a/d module specifications (continued) ac characteristics standard operating conditions: 3.3v and 5.0v (10%) (unless otherwise stated) operating temperature -40c t a +85c for industrial -40 c t a +125c for extended param no. symbol characteristic min. typ max. units conditions legend: tbd = to be determined note 1: because the sample caps will eventually lose charge, clock rates below 10 khz can affect linearity performance, especially at elevated temperatures. 2: the a/d conversion result never decreases with an increase in the input voltage, and has no missing codes. t ad a/d data adbufxx 90 2 1 0 old data new data conv a/d clock trigger pulse tconv
dspic30f1010/202x ds70178a-page 256 advance information ? 2006 microchip technology inc. table 21-34: comparator operating conditions table 21-35: comparator ac and dc specifications table 21-36: dac dc specifications table 21-37: dac ac specifications sym characteristic min typ max units comments v dd voltage range 3.0 ? 3.6 v operating range of 3.0 v-3.6v v dd voltage range 4.5 ? 5.5 v operating range of 4.5 v-5.5 v t emp temperature range -40 ? 105 c note that junction temperature can exceed 125c under these ambient conditions. standard operating conditions (unless otherwise stated) operating temperature: -40c t a +105c sym characteristic min typ max units comments v ioff input offset voltage 5 15 mv v icm input common mode voltage range 0v dd ? 1.5 v v gain open loop gain 90 db cmrr common mode rejection ratio 70 db t resp large signal response 20 30 ns v+ input step of 100mv while v- input held at av dd /2. delay measured from analog input pin to pwm output pin. standard operating conditions (unless otherwise stated) operating temperature: -40c t a +105c sym characteristic min typ max units comments cv rsrc input reference voltage 0 av dd ? 1.6 v cv res resolution 10 bits inl dnl transfer function accuracy integral non-linearity error differential non-linearity error offset error gain error tbd tbd tbd tbd 1 0.8 2 2.0 tbd tbd tbd tbd lsb lsb lsb lsb av dd = 5 v, dacref = (av dd /2) v legend: tbd = to be determined standard operating conditions (unless otherwise stated) operating temperature: -40c t a +125c sym characteristic min typ max units comments t set settling time 2.0 s measured when range = 1 (high range), and cmref<9:0> transitions from 0x1ff to 0x300.
? 2006 microchip technology inc. advance information ds70178a-page 257 dspic30f1010/202x 22.0 package marking information xxxxxxxxxxxxxxxxx yywwnnn 28-lead pdip (skinny dip) example xxxxxxxxxxxxxxxxx 0348017 dspic30f202x-30i/sp 28-lead soic yywwnnn example xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx 0348017 dspic30f202x-30i/so note : in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line thus limiting the number of available characters for customer specific information. * standard device marking consists of microchip part number, year code, week code and traceability code. for device marking beyond this, certain price adders apply. please check with your microchip sales office. for qtp devices, any special marking adders are included in qtp price. 28-lead qfn-s xxxxxxx xxxxxxx yywwnnn example dspic30f1010 -30i/mm 040700u 44-lead tqfp xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx yywwnnn example dspic30f202x -i/pt 0510017 legend: xx...x customer specific information* y year code (last digit of calendar year) yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week ?01?) nnn alphanumeric traceability code xxxxxxxxxx 44-lead qfn xxxxxxxxxx xxxxxxxxxx yywwnnn dspic30f202x example -i/ml 0510017
dspic30f1010/202x ds70178a-page 258 advance information ? 2006 microchip technology inc. 28-lead plastic quad flat no lead package (mm) 6x6x0.9 mm body (qfn-s) ? with 0.40 mm contact length (saw singulated) e2 e d d2 2 1 2 1 e b k n l exposed metal pad (note 2) optional index area (note 1) alternate index indicators see detail bottom view top view a a1 detail alternate pad outline inches nom .026 bsc number of pins overall width overall length overall height contact length exposed pad width exposed pad length * controlling parameter lead width notes: standoff pitch d2 .144 .232 .013 .012 b l d units dimension limits a1 e2 min .000 .144 .232 e a e n .031 .015 .016 .236 .146 .240 .148 .017 .020 3.65 5.90 0.33 0.30 0.38 0.40 6.00 3.70 max .001 .146 .236 .035 28 .002 .039 .148 .240 millimeters * 0.65 bsc 3.65 0.00 0.80 5.90 min 6.00 0.90 0.02 3.70 nom 28 3.75 6.10 0.43 0.50 1.00 0.05 3.75 6.10 max bsc: basic dimension. theoretically exact value shown without tolerances. see asme y14.5m 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. exposed pad varies according to die attach paddle size. .008 contact-to-exposed pad k ? ??0.20 ? significant characteristic drawing no. c04-124 revised 1-12-06
? 2006 microchip technology inc. advance information ds70178a-page 259 dspic30f1010/202x 28-lead skinny plastic dual in-line (sp) ? 300 mil body (pdip) 15 10 5 15 10 5 mold draft angle bottom 15 10 5 15 10 5 mold draft angle top 10.92 8.89 8.13 .430 .350 .320 eb overall row spacing 0.56 0.48 0.41 .022 .019 .016 b lower lead width 1.65 1.33 1.02 .065 .053 .040 b1 upper lead width 0.38 0.29 0.20 .015 .012 .008 c lead thickness 3.43 3.30 3.18 .135 .130 .125 l tip to seating plane 35.18 34.67 34.16 1.385 1.365 1.345 d overall length 7.49 7.24 6.99 .295 .285 .275 e1 molded package width 8.26 7.87 7.62 .325 .310 .300 e shoulder to shoulder width 0.38 .015 a1 base to seating plane 3.43 3.30 3.18 .135 .130 .125 a2 molded package thickness 4.06 3.81 3.56 .160 .150 .140 a top to seating plane 2.54 .100 p pitch 28 28 n number of pins max nom min max nom min dimension limits millimeters inches * units 2 1 d n e1 c eb e p l a2 b b1 a a1 notes: jedec equivalent: mo-095 drawing no. c04-070 * controlling parameter dimension d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010? (0.254mm) per sid e. significant characteristic
dspic30f1010/202x ds70178a-page 260 advance information ? 2006 microchip technology inc. 28-lead plastic small outline (so) ? wide, 300 mil body (soic) foot angle top 048048 15 12 0 15 12 0 mold draft angle bottom 15 12 0 15 12 0 mold draft angle top 0.51 0.42 0.36 .020 .017 .014 b lead width 0.33 0.28 0.23 .013 .011 .009 c lead thickness 1.27 0.84 0.41 .050 .033 .016 l foot length 0.74 0.50 0.25 .029 .020 .010 h chamfer distance 18.08 17.87 17.65 .712 .704 .695 d overall length 7.59 7.49 7.32 .299 .295 .288 e1 molded package width 10.67 10.34 10.01 .420 .407 .394 e overall width 0.30 0.20 0.10 .012 .008 .004 a1 standoff 2.39 2.31 2.24 .094 .091 .088 a2 molded package thickness 2.64 2.50 2.36 .104 .099 .093 a overall height 1.27 .050 p pitch 28 28 n number of pins max nom min max nom min dimension limits millimeters inches * units 2 1 d p n b e e1 l c 45 h a2 a a1 * controlling parameter notes: dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010? (0.254mm) per si de. jedec equivalent: ms-013 drawing no. c04-052 significant characteristic
? 2006 microchip technology inc. advance information ds70178a-page 261 dspic30f1010/202x 44-lead plastic thin-quad flatpack (pt) 10x10x1 mm body, 1.0/0.10 mm lead form (tqfp) f a a1 a2 e e1 #leads=n1 p b d1 d n 1 2 c l ch x 45 1.14 0.89 0.64 .045 .035 .025 ch pin 1 corner chamfer 1.00 ref. .039 ref. f footprint (reference) units inches millimeters * dimension limits min nom max min nom max number of pins n 44 44 pitch p .031 0.80 overall height a .039 .043 .047 1.00 1.10 1.20 molded package thickness a2 .037 .039 .041 0.95 1.00 1.05 standoff a1 .002 .004 .006 0.05 0.10 0.15 foot length l .018 .024 .030 0.45 0.60 0.75 foot angle 03.5 7 03.5 7 overall width e .463 .472 .482 11.75 12.00 12.25 overall length d .463 .472 .482 11.75 12.00 12.25 molded package width e1 .390 .394 .398 9.90 10.00 10.10 molded package length d1 .390 .394 .398 9.90 10.00 10.10 pins per side n1 11 11 lead thickness c .004 .006 .008 0.09 0.15 0.20 lead width b .012 .015 .017 0.30 0.38 0.44 mold draft angle top 5 10 15 5 10 15 mold draft angle bottom 5 10 15 5 10 15 dimensions d and e1 do not include mold flash or protrusions. mo ld flash or protrusions shall not exceed .010" (0.254mm) per s ide. notes: jedec equivalent: ms-026 revised 07-22-05 * controlling parameter ref: reference dimension, usually without tolerance, for information purposes only. see asme y14.5m drawing no. c04-076
dspic30f1010/202x ds70178a-page 262 advance information ? 2006 microchip technology inc. 44-lead plastic quad flat no lead package (ml) 8x8 mm body (qfn) d2 d top view n 1 l e2 bottom view b e 2 pin 1 index on exposed pad ( note 1 ) index area optional detail: contact variants (profile may vary) p a1 a a3 exposed metal pad ( note 2 ) k inches nom .026 bsc .010 ref bsc: basic dimension. theoretically exact value shown without tolerances. ref: reference dimension, usually without tolerance, for information purposes only. number of contacts overall height see asme y14.5m see asme y14.5m contact width * controlling parameter overall width overall length contact length exposed pad width exposed pad length jedec equivalent: m0-220 base thickness notes: pitch standoff units dimension limits a1 a b d e2 d2 a3 p .000 .309 .309 .236 .236 .014 .008 l e .031 min n .258 .013 .016 .315 .258 .315 .035 .001 .260 .321 .013 .019 .260 .002 .039 .321 max 44 0.65 bsc 0.25 ref 7.85 5.99 5.99 0.35 0.20 0.80 7.85 0 0.33 8.00 0.40 6.55 6.55 0.90 0.02 8.00 millimeters * min nom 44 8.15 6.60 6.60 0.48 0.35 1.00 0.05 8.15 max 1. pin 1 visual index feature may vary, but must be located within the hatched area. 2. exposed pad varies according to die attach paddle size. contact-to-exposed-pad k.014 - - 0.20 -- significant characteristic revised 09-12-05 drawing no. c04-103
? 2006 microchip technology inc. advance information ds70178a-page 263 dspic30f1010/202x the microchip web site microchip provides online support via our www site at www.microchip.com. this web site is used as a means to make files and information easily available to customers. accessible by using your favorite internet browser, the web site contains the following information: ? product support ? data sheets and errata, application notes and sample programs, design resources, user?s guides and hardware support documents, latest software releases and archived software ? general technical support ? frequently asked questions (faq), technical support requests, online discussion groups, microchip consultant program member listing ? business of microchip ? product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives customer change notification service microchip?s customer notification service helps keep customers current on microchip products. subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com, click on customer change notification and follow the registration instructions. customer support users of microchip products can receive assistance through several channels: ? distributor or representative ? local sales office ? field application engineer (fae) ? technical support customers should contact their distributor, representative or field application engineer (fae) for support. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://support.microchip.com
dspic30f1010/202x ds70178a-page 264 advance information ? 2006 microchip technology inc. reader response it is our intention to provide you with the best documentation possible to ensure successful use of your microchip prod- uct. if you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation can better serve you, please fax your comments to the technical publications manager at (480) 792-4150. please list the following information, and use this outline to provide us with your comments about this document. to : technical publications manager re: reader response total pages sent ________ from: name company address city / state / zip / country telephone: (_______) _________ - _________ application (optional): would you like a reply? y n device: literature number: questions: fax: (______) _________ - _________ ds70178a dspic30f1010/202x 1. what are the best features of this document? 2. how does this document meet your hardware and software development needs? 3. do you find the organization of this document easy to follow? if not, why? 4. what additions to the document do you think would enhance the structure and subject? 5. what deletions from the document could be made without affecting the overall usefulness? 6. is there any incorrect or misleading information (what and where)? 7. how would you improve this document?
? 2006 microchip technology inc. advance information ds70178a-page 265 dspic30f1010/202x appendix a: revision history revision a (june 2006) ? initial release of this document.
dspic30f1010/202x ds70178a-page 266 advance information ? 2006 microchip technology inc. notes:
? 2006 microchip technology inc. advance information ds70178a-page 267 dspic30f1010/202x index a a/d .................................................................................... 165 configuring analog port............................................ 182 ac characteristics ............................................................ 232 load conditions ........................................................ 232 ac temperature and voltage specifications .................... 232 address generator units .................................................... 43 alternate vector table ........................................................ 53 assembler mpasm assembler................................................... 222 automatic clock stretch.................................................... 152 during 10-bit addressing (stren = 1)..................... 152 during 7-bit addressing (stren = 1)....................... 152 receive mode ........................................................... 152 transmit mode .......................................................... 152 b band gap start-up time requirements............................................................ 239 timing characteristics .............................................. 239 barrel shifter ....................................................................... 29 baud rate error calculation (brgh = 0) ......................... 158 bit-reversed addressing .................................................... 47 example ...................................................................... 47 implementation ........................................................... 47 modifier values (table) ................................................ 48 sequence table (16-entry)......................................... 48 block diagrams 16-bit timer1 module .................................................. 88 dsp engine ................................................................ 26 dspic30f2020 ............................................................ 10 dspic30f2023 ............................................................ 16 external power-on reset circuit............................... 207 i 2 c............................................................................. 150 input capture mode .................................................... 97 oscillator system ...................................................... 199 output compare mode ............................................. 101 reset system............................................................ 205 shared port structure ................................................. 77 spi ............................................................................ 146 spi master/slave connection ................................... 146 uart ........................................................................ 157 brown-out reset timing requirements................................................ 238 c c compilers mplab c18 .............................................................. 222 mplab c30 .............................................................. 222 clkout and i/o timing characteristics .......................................................... 236 requirements............................................................ 236 code examples erasing a row of program memory............................ 83 initiating a programming sequence............................ 84 loading write latches ................................................ 84 code protection ................................................................ 191 configuring analog port pins.............................................. 78 control registers ................................................................ 82 nvmadr .................................................................... 82 nvmadru.................................................................. 82 nvmcon .................................................................... 82 nvmkey..................................................................... 82 core architecture overview..................................................................... 21 core register map.............................................................. 39 customer change notification service............................. 263 customer notification service .......................................... 263 customer support............................................................. 263 d data access from program memory using program space visibility............................................. 34 data accumulators and adder/subtractor .......................... 27 data space write saturation ...................................... 29 overflow and saturation ............................................. 27 round logic ............................................................... 28 write back .................................................................. 28 data address space........................................................... 35 alignment.................................................................... 38 alignment (figure) ...................................................... 38 mcu and dsp (mac class) instructions ................... 37 memory map......................................................... 35, 36 near data space ........................................................ 39 software stack ........................................................... 39 spaces........................................................................ 38 width .......................................................................... 38 dc characteristics i/o pin input specifications ...................................... 228 i/o pin output specifications.................................... 231 idle current (i idle ) .................................................... 228 operating current (i dd ) ............................................ 227 power-down current (i pd )........................................ 229 program and eeprom ............................................ 231 development support ....................................................... 221 device configuration register map ............................................................ 212 device configuration registers ........................................ 210 fgs .......................................................................... 210 fosc........................................................................ 210 fwdt ....................................................................... 210 device overview................................................................... 9 divide support .................................................................... 24 dsp engine ........................................................................ 25 multiplier ..................................................................... 27 dspic30f2020 block diagram ........................................... 13 dual output compare match mode .................................. 102 continuous pulse mode ........................................... 102 single pulse mode.................................................... 102 e electrical characteristics .................................................. 225 ac............................................................................. 232 equations i 2 c ............................................................................ 154 uart baud rate with brgh = 0 ............................. 158 uart baud rate with brgh = 1 ............................. 158 errata .................................................................................... 8 external clock input.......................................................... 201 external clock timing characteristics type a, b and c timer ............................................. 240 external clock timing requirements ............................... 233 type a timer ............................................................ 240 type b timer ............................................................ 241 type c timer............................................................ 241 external interrupt requests ................................................ 53
dspic30f1010/202x ds70178a-page 268 advance information ? 2006 microchip technology inc. f fast context saving............................................................ 53 firmware instructions........................................................ 213 flash program memory....................................................... 81 in-circuit serial programming (icsp) ......................... 81 run time self-programming (rtsp) ......................... 81 table instruction operation summary ........................ 81 i i/o pin specifications input .......................................................................... 228 output ....................................................................... 231 i/o ports .............................................................................. 77 parallel i/o (pio)......................................................... 77 i 2 c ..................................................................................... 149 i 2 c 10-bit slave mode operation ...................................... 151 reception .................................................................. 151 transmission............................................................. 151 i 2 c 7-bit slave mode operation ........................................ 151 reception .................................................................. 151 transmission............................................................. 151 i 2 c master mode baud rate generator ................................................ 154 clock arbitration........................................................ 154 multi-master communication, bus collision and bus arbitration .................................................. 154 reception .................................................................. 153 transmission............................................................. 153 i 2 c module addresses ................................................................. 151 bus data timing characteristics master mode ..................................................... 250 slave mode ....................................................... 252 bus data timing requirements master mode ..................................................... 251 slave mode ....................................................... 253 bus start/stop bits timing characteristics master mode ..................................................... 250 slave mode ....................................................... 252 general call address support .................................. 153 interrupts................................................................... 152 ipmi support ............................................................. 153 master operation ...................................................... 153 master support ......................................................... 153 operating function description ................................ 149 operation during cpu sleep and idle modes .......... 154 pin configuration ...................................................... 149 programmer?s model................................................. 149 register map............................................................. 155 registers................................................................... 149 slope control ............................................................ 153 software controlled clock stretching (stren = 1).. 152 various modes .......................................................... 149 idle current (i idle )............................................................. 228 in-circuit debugger ........................................................... 211 in-circuit serial programming (icsp) ............................... 191 initialization condition for rcon register case 1............ 208 initialization condition for rcon register case 2............ 208 input capture (capx) timing characteristics................... 242 input capture interrupts ...................................................... 99 register map............................................................. 100 input capture module.......................................................... 97 simple capture event mode ....................................... 98 sleep and idle modes ................................................. 99 input capture timing requirements ................................. 242 input change notification.................................................... 78 input change notification register map ............................. 80 instruction addressing modes ............................................ 43 file register instructions ............................................ 43 fundamental modes supported ................................. 43 mac instructions ........................................................ 44 mcu instructions ........................................................ 44 move and accumulator instructions............................ 44 other instructions ....................................................... 44 instruction set................................................................... 213 instruction set overview................................................... 216 inter-integrated circuit. see i 2 c internal clock timing examples ....................................... 234 internet address ............................................................... 263 interrupt priority .................................................................. 50 interrupt sequence ............................................................. 53 interrupt stack frame ................................................. 53 interrupts............................................................................. 49 traps .......................................................................... 51 l load conditions................................................................ 232 m memory organization ......................................................... 31 microchip internet web site.............................................. 263 modulo addressing ............................................................. 45 applicability................................................................. 47 operation example ..................................................... 46 start and end address ............................................... 45 w address register selection .................................... 45 motor control pwm module fault timing characteristics ..................................... 244 timing characteristics .............................................. 244 timing requirements................................................ 244 mplab asm30 assembler, linker, librarian ................... 222 mplab icd 2 in-circuit debugger ................................... 223 mplab ice 2000 high-performance universal in-circuit emulator ............................................................ 223 mplab ice 4000 high-performance universal in-circuit emulator .................................................... 223 mplab integrated development environment software.. 221 mplab pm3 device programmer .................................... 223 mplink object linker/mplib object librarian ................ 222 o oc/pwm module timing characteristics ......................... 243 operating current (i dd ) .................................................... 227 oscillator operating modes (table).......................................... 198 system overview...................................................... 191 oscillator configurations................................................... 200 fail-safe clock monitor ............................................ 202 initial clock source selection ................................... 200 phase locked loop (pll) ........................................ 200 start-up timer (ost) ................................................ 200 oscillator selection ........................................................... 191 oscillator start-up timer timing characteristics .............................................. 237 timing requirements................................................ 238 output compare interrupts ............................................... 104 output compare mode register map ............................................................ 105 output compare module .................................................. 101 timing characteristics .............................................. 242 timing requirements................................................ 242 output compare operation during cpu idle mode ......... 103 output compare sleep mode operation .......................... 103
? 2006 microchip technology inc. advance information ds70178a-page 269 dspic30f1010/202x p packaging information marking ..................................................................... 257 picstart plus development programmer ..................... 224 pinout descriptions ................................................. 11, 14, 17 pll clock timing specifications....................................... 234 por. see power-on reset port register map dspic30f2020 ............................................................ 79 dspic30f2023 ............................................................ 80 port write/read example ................................................... 78 power-down current (i pd ) ................................................ 229 power-on reset (por) ..................................................... 191 oscillator start-up timer (ost) ................................ 191 power-up timer (pwrt) .......................................... 191 power-saving modes ........................................................ 209 idle ............................................................................ 210 sleep......................................................................... 209 power-saving modes (sleep and idle) ............................. 191 power-up timer timing characteristics .............................................. 237 timing requirements................................................ 238 product identification system ........................................... 271 program address space ..................................................... 31 construction................................................................ 32 data access from program memory using table instructions ......................................................... 33 data access from, address generation...................... 32 memory map ............................................................... 31 table instructions tblrdh ............................................................. 33 tblrdl .............................................................. 33 tblwth ............................................................. 33 tblwtl.............................................................. 33 program and eeprom characteristics ............................ 231 program counter ................................................................ 22 program data table access ............................................... 34 program space visibility window into program space operation...................... 35 programmer?s model........................................................... 22 diagram ...................................................................... 23 programming operations.................................................... 83 algorithm for program flash ....................................... 83 erasing a row of program memory............................ 83 initiating the programming sequence......................... 84 loading write latches ................................................ 84 programming, device instructions .................................... 213 r reader response ............................................................. 264 reset......................................................................... 191, 204 reset sequence ................................................................. 51 reset sources ............................................................ 51 reset timing characteristics ............................................ 237 reset timing requirements ............................................. 238 resets por .......................................................................... 206 por with long crystal start-up time....................... 207 por, operating without fscm and pwrt .............. 207 rtsp operation.................................................................. 82 s sales and support ............................................................ 271 serial peripheral interface. see spi simple capture event mode capture buffer operation ........................................... 98 capture prescaler....................................................... 98 hall sensor mode ....................................................... 98 input capture in cpu idle mode................................. 99 timer2 and timer3 selection mode ........................... 98 simple oc/pwm mode timing requirements ................. 243 simple output compare match mode .............................. 102 simple pwm mode ........................................................... 102 period ....................................................................... 103 software simulator (mplab sim) .................................... 222 software stack pointer, frame pointer .............................. 22 call stack frame ..................................................... 39 spi .................................................................................... 145 spi mode slave select synchronization ................................... 147 spi1 register map ................................................... 148 spi module ....................................................................... 145 framed spi support................................................. 146 operating function description ................................ 145 sdox disable ........................................................... 145 timing characteristics master mode (cke = 0).................................... 245 master mode (cke = 1).................................... 246 slave mode (cke = 1).............................. 247, 248 timing requirements master mode (cke = 0).................................... 245 master mode (cke = 1).................................... 246 slave mode (cke = 0)...................................... 247 slave mode (cke = 1)...................................... 249 word and byte communication................................ 145 spi operation during cpu idle mode .............................. 147 spi operation during cpu sleep mode........................... 147 status register ............................................................... 22 symbols used in opcode descriptions ............................. 214 system integration............................................................ 191 register map ............................................................ 212 t temperature and voltage specifications ac............................................................................. 232 timer1 module.................................................................... 87 16-bit asynchronous counter mode ........................... 87 16-bit synchronous counter mode............................. 87 16-bit timer mode ...................................................... 87 gate operation ........................................................... 88 interrupt ...................................................................... 89 operation during sleep mode .................................... 88 prescaler .................................................................... 88 register map .............................................................. 90 timer2 and timer3 selection mode.................................. 102 timer2/3 module................................................................. 91 16-bit timer mode ...................................................... 91 32-bit synchronous counter mode............................. 91 32-bit timer mode ...................................................... 91 adc event trigger ..................................................... 94 gate operation ........................................................... 94 interrupt ...................................................................... 94 operation during sleep mode .................................... 94 register map .............................................................. 95 timer prescaler .......................................................... 94
dspic30f1010/202x ds70178a-page 270 advance information ? 2006 microchip technology inc. timing characteristics a/d conversion 10-bit high-speed (chps = 01, simsam = 0, asam = 0, ssrc = 000) .... 255 band gap start-up time ........................................... 239 clkout and i/o....................................................... 236 external clock........................................................... 232 i 2 c bus data master mode ..................................................... 250 slave mode ....................................................... 252 i 2 c bus start/stop bits master mode ..................................................... 250 slave mode ....................................................... 252 input capture (capx) ............................................... 242 motor control pwm module...................................... 244 motor control pwm module falult ............................ 244 oc/pwm module ...................................................... 243 oscillator start-up timer ........... ................................ 237 output compare module........................................... 242 power-up timer ........................................................ 237 reset......................................................................... 237 spi module master mode (cke = 0) .................................... 245 master mode (cke = 1) .................................... 246 slave mode (cke = 0) ...................................... 247 slave mode (cke = 1) ...................................... 248 type a, b and c timer external clock ..................... 240 watchdog timer........................................................ 237 timing diagrams pwm output ............................................................. 104 time-out sequence on power-up (mclr not tied to v dd ), case 1......................................... 206 time-out sequence on power-up (mclr not tied to v dd ), case 2......................................... 207 time-out sequence on power-up (mclr tied to v dd ) .............................................................. 206 timing diagrams and specifications dc characteristics - internal rc accuracy ............... 234 timing diagrams.see timing characteristics timing requirements band gap start-up time ........................................... 239 brown-out reset ....................................................... 238 clkout and i/o....................................................... 236 external clock........................................................... 233 i 2 c bus data (master mode)..................................... 251 i 2 c bus data (slave mode)....................................... 253 input capture ............................................................ 242 motor control pwm module...................................... 244 oscillator start-up timer ........... ................................ 238 output compare module........................................... 242 power-up timer ........................................................ 238 reset......................................................................... 238 simple oc/pwm mode ............................................. 243 spi module master mode (cke = 0) .................................... 245 master mode (cke = 1) .................................... 246 slave mode (cke = 0) ...................................... 247 slave mode (cke = 1) ...................................... 249 type a timer external clock .................................... 240 type b timer external clock .................................... 241 type c timer external clock .................................... 241 watchdog timer........................................................ 238 timing specifications pll clock.................................................................. 234 traps trap sources .............................................................. 51 u uart baud rate generator (brg) .................................... 158 enabling and setting up uart ................................ 158 irda built-in encoder and decoder........................... 159 receiving 8-bit or 9-bit data mode.................................... 159 transmitting 8-bit data mode ................................................ 159 9-bit data mode ................................................ 159 break and sync sequence ............................... 159 uart module uart1 register map................................................ 164 unit id locations .............................................................. 191 universal asynchronous receiver transmitter. see uart w wake-up from sleep ......................................................... 191 wake-up from sleep and idle ............................................. 53 watchdog timer timing characteristics .............................................. 237 timing requirements................................................ 238 watchdog timer (wdt)............................................ 191, 209 enabling and disabling ............................................. 209 operation .................................................................. 209 www address ................................................................. 263 www, on-line support .................... ................................... 8
? 2006 microchip technology inc. advance information ds70178a-page 271 dspic30f1010/202x product identification system to order or obtain information, e.g. , on pricing or delivery, refer to the factory or the listed sales office. dspic30f2020at-30e/so-es example: dspic30f2020at-301/so = 30 mips, industrial temp., soic package, rev. a trademark architecture flash e = extended high temp -40c to +125c i = industrial -40c to +85c temperature device id package mm = qfn pt = tqfp sp = spdip so = soic s = die (waffle pack) w = die (wafers) memory size in bytes 0 = romless 1 = 1k to 6k 2 = 7k to 12k 3 = 13k to 24k 4 = 25k to 48k 5 = 49k to 96k 6 = 97k to 192k 7 = 193k to 384k 8 = 385k to 768k 9 = 769k and up custom id (3 digits) or t = tape and reel a,b,c? = revision level engineering sample (es) speed 20 = 20 mips 30 = 30 mips
ds70178a-page 272 advance information ? 2006 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com asia pacific office suites 3707-14, 37th floor tower 6, the gateway habour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 atlanta alpharetta, ga tel: 770-640-0034 fax: 770-640-0307 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 san jose mountain view, ca tel: 650-215-1444 fax: 650-961-0286 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8676-6200 fax: 86-28-8676-6599 china - fuzhou tel: 86-591-8750-3506 fax: 86-591-8750-3521 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - shunde tel: 86-757-2839-5507 fax: 86-757-2839-5571 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xian tel: 86-29-8833-7250 fax: 86-29-8833-7256 asia/pacific india - bangalore tel: 91-80-4182-8400 fax: 91-80-4182-8422 india - new delhi tel: 91-11-5160-8631 fax: 91-11-5160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - gumi tel: 82-54-473-4301 fax: 82-54-473-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - penang tel: 60-4-646-8870 fax: 60-4-646-5086 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-572-9526 fax: 886-3-572-6459 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-3910 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 06/08/06


▲Up To Search▲   

 
Price & Availability of DSPIC30F6020BT-20E

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X